From patchwork Sun Apr 11 04:04:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 57970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bilbo.ozlabs.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.3.1 X-Original-To: tony@bakeyournoodle.com Delivered-To: tony@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 3A4E5B7EFE for ; Sun, 11 Apr 2010 18:48:38 +1000 (EST) Received: by ozlabs.org (Postfix, from userid 1010) id 32A65B7D21; Sun, 11 Apr 2010 14:07:31 +1000 (EST) Date: Sun, 11 Apr 2010 14:04:27 +1000 From: Anton Blanchard To: yaboot-devel@lists.ozlabs.org Subject: [PATCH 4/10] Remove magic numbers in print_message_file Message-ID: <20100411040427.GA11751@kryten> References: <20100411040149.GA3142@kryten> <20100411040226.GB3142@kryten> <20100411040256.GC3142@kryten> <20100411040321.GD3142@kryten> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100411040321.GD3142@kryten> User-Agent: Mutt/1.5.20 (2009-06-14) X-Mailman-Approved-At: Sun, 11 Apr 2010 18:48:32 +1000 X-BeenThere: yaboot-devel@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Technical and development discussion regarding yaboot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: yaboot-devel-bounces+tony=bakeyournoodle.com@lists.ozlabs.org Errors-To: yaboot-devel-bounces+tony=bakeyournoodle.com@lists.ozlabs.org Content-Length: 1155 Lines: 40 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);