From patchwork Wed Oct 20 11:17:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 71904 X-Patchwork-Delegate: wd@denx.de Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 7B438136321 for ; Wed, 20 Oct 2010 13:18:59 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 6BAEC348C9D2 for ; Wed, 20 Oct 2010 13:18:59 +0200 (CEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Wed, 20 Oct 2010 13:18:59 +0200 (CEST) Received: from murder ([192.168.6.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Wed, 20 Oct 2010 13:18:35 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend3.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Wed, 20 Oct 2010 13:18:34 +0200 Received: from scanner-4.m-online.net (scanner-4.mail.m-online.net [192.168.1.18]) by mail.m-online.net (Postfix) with ESMTP id E053A1C0008C; Wed, 20 Oct 2010 13:18:34 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-2.m-online.net (Postfix) with ESMTP id C061046AF1A; Wed, 20 Oct 2010 13:18:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 25B3F282B6; Wed, 20 Oct 2010 13:18:16 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K4UJzN92mHOW; Wed, 20 Oct 2010 13:18:15 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D6C20281FD; Wed, 20 Oct 2010 13:18:09 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D1514281FD for ; Wed, 20 Oct 2010 13:18:06 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yUacdCX-clBo for ; Wed, 20 Oct 2010 13:18:06 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by theia.denx.de (Postfix) with ESMTPS id AA9BC28356 for ; Wed, 20 Oct 2010 13:18:02 +0200 (CEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 0790A1B4249 for ; Wed, 20 Oct 2010 11:18:00 +0000 (UTC) From: Mike Frysinger To: u-boot@lists.denx.de Date: Wed, 20 Oct 2010 07:17:39 -0400 Message-Id: <1287573459-6658-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.3.1 Subject: [U-Boot] [PATCH] image: constify lookup tables X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net These are pure lookup tables -- no need to be writable. Signed-off-by: Mike Frysinger --- common/image.c | 14 +++++++------- include/image.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/image.c b/common/image.c index 385464d..0005fc5 100644 --- a/common/image.c +++ b/common/image.c @@ -74,7 +74,7 @@ static const image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch, #include #endif /* !USE_HOSTCC*/ -static table_entry_t uimage_arch[] = { +static const table_entry_t uimage_arch[] = { { IH_ARCH_INVALID, NULL, "Invalid ARCH", }, { IH_ARCH_ALPHA, "alpha", "Alpha", }, { IH_ARCH_ARM, "arm", "ARM", }, @@ -96,7 +96,7 @@ static table_entry_t uimage_arch[] = { { -1, "", "", }, }; -static table_entry_t uimage_os[] = { +static const table_entry_t uimage_os[] = { { IH_OS_INVALID, NULL, "Invalid OS", }, { IH_OS_LINUX, "linux", "Linux", }, #if defined(CONFIG_LYNXKDI) || defined(USE_HOSTCC) @@ -129,7 +129,7 @@ static table_entry_t uimage_os[] = { { -1, "", "", }, }; -static table_entry_t uimage_type[] = { +static const table_entry_t uimage_type[] = { { IH_TYPE_INVALID, NULL, "Invalid Image", }, { IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image", }, { IH_TYPE_FIRMWARE, "firmware", "Firmware", }, @@ -144,7 +144,7 @@ static table_entry_t uimage_type[] = { { -1, "", "", }, }; -static table_entry_t uimage_comp[] = { +static const table_entry_t uimage_comp[] = { { IH_COMP_NONE, "none", "uncompressed", }, { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", }, { IH_COMP_GZIP, "gzip", "gzip compressed", }, @@ -516,7 +516,7 @@ static void genimg_print_time (time_t timestamp) * long entry name if translation succeeds * msg otherwise */ -char *get_table_entry_name (table_entry_t *table, char *msg, int id) +char *get_table_entry_name(const table_entry_t *table, char *msg, int id) { for (; table->id >= 0; ++table) { if (table->id == id) @@ -563,10 +563,10 @@ const char *genimg_get_comp_name (uint8_t comp) * entry id if translation succeeds * -1 otherwise */ -int get_table_entry_id (table_entry_t *table, +int get_table_entry_id(const table_entry_t *table, const char *table_name, const char *name) { - table_entry_t *t; + const table_entry_t *t; #ifdef USE_HOSTCC int first = 1; diff --git a/include/image.h b/include/image.h index 49d6280..005e0d2 100644 --- a/include/image.h +++ b/include/image.h @@ -300,14 +300,14 @@ typedef struct table_entry { * entry that matches the given short name. If a matching entry is * found, it's id is returned to the caller. */ -int get_table_entry_id (table_entry_t *table, +int get_table_entry_id(const table_entry_t *table, const char *table_name, const char *name); /* * get_table_entry_name() scans the translation table trying to find * an entry that matches the given id. If a matching entry is found, * its long name is returned to the caller. */ -char *get_table_entry_name (table_entry_t *table, char *msg, int id); +char *get_table_entry_name(const table_entry_t *table, char *msg, int id); const char *genimg_get_os_name (uint8_t os); const char *genimg_get_arch_name (uint8_t arch);