From patchwork Tue Jan 13 19:04:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 428606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id DC52B1401F0; Wed, 14 Jan 2015 06:07:33 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1YB6oO-0002Cf-Kx; Tue, 13 Jan 2015 19:07:32 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1YB6nC-0001vo-NG for fwts-devel@lists.ubuntu.com; Tue, 13 Jan 2015 19:06:18 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginm.net ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1YB6nC-0004Hr-KX for fwts-devel@lists.ubuntu.com; Tue, 13 Jan 2015 19:06:18 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 34/46] lib: fwts_memorymap: reduce scope of variables Date: Tue, 13 Jan 2015 19:04:53 +0000 Message-Id: <1421175905-17035-35-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421175905-17035-1-git-send-email-colin.king@canonical.com> References: <1421175905-17035-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King cppcheck is picking up some minor style issues which can be easily fixed: [src/lib/src/fwts_memorymap.c:121]: (style) The scope of the variable 'entry' can be reduced. [src/lib/src/fwts_memorymap.c:135]: (style) The scope of the variable 'entry' can be reduced. [src/lib/src/fwts_memorymap.c:184]: (style) The scope of the variable 'end' can be reduced. Signed-off-by: Colin Ian King Acked-by: Ivan Hu Acked-by: Alex Hung --- src/lib/src/fwts_memorymap.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/src/fwts_memorymap.c b/src/lib/src/fwts_memorymap.c index 8482a9d..419b8ef 100644 --- a/src/lib/src/fwts_memorymap.c +++ b/src/lib/src/fwts_memorymap.c @@ -118,11 +118,10 @@ static int fwts_register_memory_map_line(fwts_list *memory_map_list, const uint6 */ int fwts_memory_map_type(fwts_list *memory_map_list, const uint64_t memory) { - fwts_memory_map_entry *entry; fwts_list_link *item; fwts_list_foreach(item, memory_map_list) { - entry = fwts_list_data(fwts_memory_map_entry*, item); + fwts_memory_map_entry *entry = fwts_list_data(fwts_memory_map_entry*, item); if (entry->start_address <= memory && entry->end_address > memory) return entry->type; } @@ -132,11 +131,10 @@ int fwts_memory_map_type(fwts_list *memory_map_list, const uint64_t memory) fwts_memory_map_entry *fwts_memory_map_info(fwts_list *memory_map_list, const uint64_t memory) { - fwts_memory_map_entry *entry; fwts_list_link *item; fwts_list_foreach(item, memory_map_list) { - entry = fwts_list_data(fwts_memory_map_entry*, item); + fwts_memory_map_entry *entry = fwts_list_data(fwts_memory_map_entry*, item); if (entry->start_address <= memory && entry->end_address > memory) return entry; } @@ -181,11 +179,12 @@ static void fwts_memory_map_dmesg_info(void *data, void *private) if ((str = strstr(line,"BIOS-memory_map:")) != NULL) { uint64_t start; - uint64_t end; start = strtoull(str+10, NULL, 16); str = strstr(line," - "); if (str) { + uint64_t end; + str += 3; end = strtoull(str, NULL, 16) - 1;