[PATCH 27/46] lib: fwts_battery: reduce scope of variables

Colin King colin.king at canonical.com
Tue Jan 13 19:04:46 UTC 2015


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

cppcheck is picking up some minor style issues which can
be easily fixed:

[src/lib/src/fwts_battery.c:142]:
	(style) The scope of the variable 'units' can be reduced.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/lib/src/fwts_battery.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lib/src/fwts_battery.c b/src/lib/src/fwts_battery.c
index 8a84998..f6eb56d 100644
--- a/src/lib/src/fwts_battery.c
+++ b/src/lib/src/fwts_battery.c
@@ -139,7 +139,6 @@ static int fwts_battery_get_capacity_proc_fs(fwts_framework *fw,
 		entry = readdir(dir);
 		if (entry && strlen(entry->d_name) > 2) {
 			char path[PATH_MAX];
-			char units[64];
 			int  val;
 			FILE *fp;
 			bool match = ((index == FWTS_BATTERY_ALL) || (index == i));
@@ -156,6 +155,8 @@ static int fwts_battery_get_capacity_proc_fs(fwts_framework *fw,
 				while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) {
 					if (strstr(buffer, field) &&
 					    strlen(buffer) > 25) {
+						char units[64];
+
 						sscanf(buffer+25, "%d %63s", &val, units);
 						if (strncmp(units, "mAh",3) == 0) {
 							*capacity_mAh += val;
-- 
2.1.4




More information about the fwts-devel mailing list