]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
build: enforce files.h usage
authorEric Blake <eblake@redhat.com>
Sat, 20 Nov 2010 00:25:23 +0000 (17:25 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 24 Nov 2010 22:23:43 +0000 (15:23 -0700)
* cfg.mk (sc_prohibit_close): New syntax-check rule.
* src/util/pci.c (pciWaitForDeviceCleanup): Fix violation.
* .x-sc_prohibit_close: New exceptions.
* Makefile.am (EXTRA_DIST): Distribute new file.

.x-sc_prohibit_close [new file with mode: 0644]
Makefile.am
cfg.mk
src/util/pci.c

diff --git a/.x-sc_prohibit_close b/.x-sc_prohibit_close
new file mode 100644 (file)
index 0000000..348200c
--- /dev/null
@@ -0,0 +1,3 @@
+^docs/.*
+^HACKING$
+^src/util/files.c$
index d3f8876b238a8ab447d3a82ed029b8e923b38872..bf1b49b5152bb5c2f90bef255caae36c71218c4d 100644 (file)
@@ -26,6 +26,7 @@ EXTRA_DIST = \
   .x-sc_bindtextdomain \
   .x-sc_m4_quote_check \
   .x-sc_prohibit_asprintf \
+  .x-sc_prohibit_close \
   .x-sc_prohibit_empty_lines_at_EOF \
   .x-sc_prohibit_gethostby \
   .x-sc_prohibit_gethostname \
diff --git a/cfg.mk b/cfg.mk
index 0851f44a8ccbd42a9c16f7063a6c49914bebe0ad..963c7db3843063c126bde090291907f7b90976d0 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -231,6 +231,15 @@ sc_avoid_write:
        halt='consider using safewrite instead of write'                \
          $(_sc_search_regexp)
 
+# Avoid functions that can lead to double-close bugs.
+sc_prohibit_close:
+       @prohibit='\<[f]close *\('                                      \
+       halt='use VIR_{FORCE_}[F]CLOSE instead of [f]close'             \
+         $(_sc_search_regexp)
+       @prohibit='\<fdopen *\('                                        \
+       halt='use VIR_FDOPEN instead of fdopen'                         \
+         $(_sc_search_regexp)
+
 # Similar to the gnulib maint.mk rule for sc_prohibit_strcmp
 # Use STREQLEN or STRPREFIX rather than comparing strncmp == 0, or != 0.
 sc_prohibit_strncmp:
index bd8c6c5442309a26ba523e0506e2b3a25fd539c6..d38cefabe6888674ae21176e560c393c65d65d78 100644 (file)
@@ -1095,7 +1095,7 @@ pciWaitForDeviceCleanup(pciDevice *dev, const char *matcher)
         }
     }
 
-    fclose(fp);
+    VIR_FORCE_FCLOSE(fp);
 
     return ret;
 }