From patchwork Sun Apr 11 04:04:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4/10] Remove magic numbers in print_message_file X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 57970 Message-Id: <20100411040427.GA11751@kryten> To: yaboot-devel@lists.ozlabs.org Date: Sun, 11 Apr 2010 14:04:27 +1000 From: Anton Blanchard List-Id: Technical and development discussion regarding yaboot Create a define instead of using a magic number in print_message_file. Signed-off-by: Anton Blanchard 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);