[PATCH 06/46] acpi: lid: reduce scope of variables

Colin King colin.king at canonical.com
Tue Jan 13 19:04:25 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/acpi/lid/lid.c:90]:
	(style) The scope of the variable 'buffer' can be reduced.
[src/acpi/lid/lid.c:175]:
	(style) The scope of the variable 'ret' can be reduced.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpi/lid/lid.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/acpi/lid/lid.c b/src/acpi/lid/lid.c
index 9c6e06d..9b891f1 100644
--- a/src/acpi/lid/lid.c
+++ b/src/acpi/lid/lid.c
@@ -87,7 +87,6 @@ static int lid_test_state(fwts_framework *fw, int button)
 	int not_matching = 0;
 	int events = 0;
 	size_t len;
-	char *buffer;
 	char *state;
 	int i;
 
@@ -117,7 +116,9 @@ static int lid_test_state(fwts_framework *fw, int button)
 		return FWTS_ERROR;
 	}
 
-	for (i=0; i<=20; i++) {
+	for (i = 0; i <= 20; i++) {
+		char *buffer;
+
 		if ((buffer = fwts_acpi_event_read(fd, &len, 1)) != NULL) {
 			if (strstr(buffer, "button/lid")) {
 				events++;
@@ -172,11 +173,12 @@ static int lid_test2(fwts_framework *fw)
 
 static int lid_test3(fwts_framework *fw)
 {
-	int ret;
 	int i;
 	fwts_log_info(fw, "Some machines may have EC or ACPI faults that cause detection of multiple open/close events to fail.");
 
-	for (i=1; i<4; i++) {
+	for (i = 1; i < 4; i++) {
+		int ret;
+
 		fwts_printf(fw, "==== %d of %d: Please close laptop lid for 2 seconds and then re-open. ====\n", i,3);
 
 		if ((ret = lid_test_state(fw, FWTS_BUTTON_LID_CLOSED)) != FWTS_OK)
-- 
2.1.4




More information about the fwts-devel mailing list