[coreboot-gerrit] Patch set updated for coreboot: 73a2008 inteltool: clean up file descriptors a bit

Stefan Tauner (stefan.tauner@gmx.at) gerrit at coreboot.org
Fri Apr 5 01:43:46 CEST 2013

Stefan Tauner (stefan.tauner at gmx.at) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3025


commit 73a20080249239a7b3fd3e04d910335f780b5040
Author: Stefan Tauner <stefan.tauner at gmx.at>
Date:   Fri Apr 5 01:23:32 2013 +0200

    inteltool: clean up file descriptors a bit
    Paul Menzel reported that Cppcheck 1.59 reported an unused variable io_fd.
    While that is true, the underlying issue is that the file descriptors are not
    closed properly at the end. "a bit" refers to the numerous exit calls all
    around that of course circumvent the cleanup.
    Arguably one could live without cleaning up because it is done automatically
    Change-Id: Ifd46314672ca431d820fb3842bfbf12decc90f9b
    Signed-off-by: Stefan Tauner <stefan.tauner at gmx.at>
 util/inteltool/inteltool.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/util/inteltool/inteltool.c b/util/inteltool/inteltool.c
index 2396eb0..6c073ce 100644
--- a/util/inteltool/inteltool.c
+++ b/util/inteltool/inteltool.c
@@ -26,9 +26,7 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 #include "inteltool.h"
-#if defined(__FreeBSD__)
 #include <unistd.h>
  * http://pci-ids.ucw.cz/read/PC/8086
@@ -307,9 +305,6 @@ int main(int argc, char *argv[])
 #if defined(__FreeBSD__)
 	int io_fd;
-#if defined(__FreeBSD__)
 	if ((io_fd = open("/dev/io", O_RDWR)) < 0) {
@@ -450,5 +445,12 @@ int main(int argc, char *argv[])
 	// pci_free_dev(sb); // TODO: glibc detected "double free or corruption"
+#if defined(__FreeBSD__)
+	close(io_fd);
+#ifndef __DARWIN__
+	close(fd_mem);
 	return 0;

More information about the coreboot-gerrit mailing list