[PATCH] acpica: fwts_iasl_interface: clean up static analyzer warning on freopen

Colin King colin.king at canonical.com
Fri May 15 10:37:16 UTC 2015


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

cppcheck is being a bit overly zealous:

[src/acpica/source/compiler/fwts_iasl_interface.c:114]:
  (error) Return value of allocation function freopen is not stored.

..but we may as well assign a file pointer to the freopen() call and
explicitly close it before calling _exit() just to make things a little
clearer to cppcheck

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpica/source/compiler/fwts_iasl_interface.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/acpica/source/compiler/fwts_iasl_interface.c b/src/acpica/source/compiler/fwts_iasl_interface.c
index 56dc76e..68338c9 100644
--- a/src/acpica/source/compiler/fwts_iasl_interface.c
+++ b/src/acpica/source/compiler/fwts_iasl_interface.c
@@ -71,13 +71,13 @@ int fwts_iasl_disassemble_aml(
 {
 	pid_t	pid;
 	int	status, i;
+	FILE *fp;
 
 	pid = fork();
 	switch (pid) {
 	case -1:
 		return -1;
 	case 0:
-
 		/* Child */
 		init_asl_core();
 
@@ -111,9 +111,10 @@ int fwts_iasl_disassemble_aml(
 		}
 
 		/* Throw away noisy errors */
-		if (freopen("/dev/null", "w", stderr) != NULL)
+		if ((fp = freopen("/dev/null", "w", stderr)) != NULL) {
 			AslDoOneFile((char *)tables[which]);
-
+			fclose(fp);
+		}
 		_exit(0);
 		break;
 	default:
-- 
2.1.4




More information about the fwts-devel mailing list