Patchwork [4/10] Remove magic numbers in print_message_file

login
register
mail settings
Submitter Anton Blanchard
Date April 11, 2010, 4:04 a.m.
Message ID <20100411040427.GA11751@kryten>
Download mbox | patch
Permalink /patch/57970/
State Changes Requested
Headers show

Comments

Anton Blanchard - April 11, 2010, 4:04 a.m.
Create a define instead of using a magic number in print_message_file.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Patch

Index: yaboot/second/yaboot.c
===================================================================
--- yaboot.orig/second/yaboot.c	2010-04-01 13:23:25.000000000 +1100
+++ yaboot/second/yaboot.c	2010-04-01 13:26:09.000000000 +1100
@@ -58,6 +58,8 @@ 
 #define CONFIG_FILE_NAME	"yaboot.conf"
 #define CONFIG_FILE_MAX		0x8000		/* 32k */
 
+#define MESSAGE_FILE_MAX	2048
+
 #ifdef USE_MD5_PASSWORDS
 #include "md5.h"
 #endif /* USE_MD5_PASSWORDS */
@@ -294,13 +296,13 @@  void print_message_file(char *filename)
      } else
 	  opened = 1;
 
-     msg = malloc(2001);
+     msg = malloc(MESSAGE_FILE_MAX + 1);
      if (!msg)
 	  goto done;
      else
-	  memset(msg, 0, 2001);
+	  memset(msg, 0, MESSAGE_FILE_MAX + 1);
 
-     if (file.fs->read(&file, 2000, msg) <= 0)
+     if (file.fs->read(&file, MESSAGE_FILE_MAX, msg) <= 0)
 	  goto done;
      else
 	  prom_printf("%s", msg);