[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fwts-devel
Subject:    [PATCH] opal: reduce scope of variable 'prop_buf'
From:       Colin King <colin.king () canonical ! com>
Date:       2017-02-19 22:09:10
Message-ID: 20170219220910.7858-1-colin.king () canonical ! com
[Download RAW message or body]

From: Colin Ian King <colin.king@canonical.com>

cppcheck style checker detected a couple of places where we can
reduce the scope of prop_buf.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/opal/cpu_info.c | 4 +++-
 src/opal/mem_info.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/opal/cpu_info.c b/src/opal/cpu_info.c
index 603163c..5b3466f 100644
--- a/src/opal/cpu_info.c
+++ b/src/opal/cpu_info.c
@@ -36,10 +36,12 @@ static int get_xscom_property(fwts_framework *fw,
 	char *prop_string = strstr(my_path, "/xscom");
 
 	if (prop_string) {
-		const char *prop_buf;
 		int prop_len;
 		int node = fdt_path_offset(fw->fdt, prop_string);
+
 		if (node >= 0) {
+			const char *prop_buf;
+
 			prop_buf = fdt_getprop(fw->fdt, node,
 					property,
 					&prop_len);
diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c
index 2b20f80..7bda7bc 100644
--- a/src/opal/mem_info.c
+++ b/src/opal/mem_info.c
@@ -36,11 +36,12 @@ static int get_dimm_property(fwts_framework *fw,
 	char *prop_string = strstr(my_path, "/memory-buffer");
 
 	if (prop_string) {
-		const char *prop_buf;
 		int prop_len;
 		int node = fdt_path_offset(fw->fdt, prop_string);
 
 		if (node >= 0) {
+			const char *prop_buf;
+
 			prop_buf = fdt_getprop(fw->fdt, node,
 					property,
 					&prop_len);
-- 
2.10.2


-- 
fwts-devel mailing list
fwts-devel@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/fwts-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic