aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2010-11-19 17:25:23 -0700
committerEric Blake <eblake@redhat.com>2010-11-24 15:23:43 -0700
commitf1fe9671e301d479c9296c08d1b9e14b4e4fe378 (patch)
treee9829395e475b21fb3d00c7ea82e3b9fb4b81770
parentAlways close drivers when a virConnectPtr is released (diff)
downloadlibvirt-f1fe9671e301d479c9296c08d1b9e14b4e4fe378.tar.gz
libvirt-f1fe9671e301d479c9296c08d1b9e14b4e4fe378.tar.bz2
libvirt-f1fe9671e301d479c9296c08d1b9e14b4e4fe378.zip
build: enforce files.h usage
* 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.
-rw-r--r--.x-sc_prohibit_close3
-rw-r--r--Makefile.am1
-rw-r--r--cfg.mk9
-rw-r--r--src/util/pci.c2
4 files changed, 14 insertions, 1 deletions
diff --git a/.x-sc_prohibit_close b/.x-sc_prohibit_close
new file mode 100644
index 000000000..348200c33
--- /dev/null
+++ b/.x-sc_prohibit_close
@@ -0,0 +1,3 @@
+^docs/.*
+^HACKING$
+^src/util/files.c$
diff --git a/Makefile.am b/Makefile.am
index d3f8876b2..bf1b49b51 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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 0851f44a8..963c7db38 100644
--- 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:
diff --git a/src/util/pci.c b/src/util/pci.c
index bd8c6c544..d38cefabe 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -1095,7 +1095,7 @@ pciWaitForDeviceCleanup(pciDevice *dev, const char *matcher)
}
}
- fclose(fp);
+ VIR_FORCE_FCLOSE(fp);
return ret;
}