Skip to contentSkip to conversation

tools/power/acpi: close file only if it is open

PATCH Applied Lv Zheng 2 participants 2 messages Mar 24, 2016 – Apr 21, 2016

Subsystems (2)
lore
Share & tools
lore

Lv Zheng

author
#0 lore raw

PATCH 1/1 tools/power/acpi: close file only if it is open

The logic on the test for a valid fd to close is incorrect. This was just a mistake and was pointed out by Colin Ian King.

---
 tools/power/acpi/tools/acpidbg/acpidbg.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/power/acpi/tools/acpidbg/acpidbg.c +2 -2
index d070fcc..a88ac45 100644
@@ -375,7 +375,7 @@ void usage(FILE *file, char *progname)
 
 int main(int argc, char **argv)
 {
-	int fd = 0;
+	int fd = -1;
 	int ch;
 	int len;
 	int ret = EXIT_SUCCESS;
@@ -430,7 +430,7 @@ int main(int argc, char **argv)
 	acpi_aml_loop(fd);
 
 exit:
-	if (fd < 0)
+	if (fd >= 0)
 		close(fd);
 	if (acpi_aml_batch_cmd)
 		free(acpi_aml_batch_cmd);
Signature · 1 line
1.7.10