1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

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.
This commit is contained in:
Eric Blake 2010-11-19 17:25:23 -07:00
parent d8b367496e
commit f1fe9671e3
4 changed files with 14 additions and 1 deletions

3
.x-sc_prohibit_close Normal file
View File

@ -0,0 +1,3 @@
^docs/.*
^HACKING$
^src/util/files.c$

View 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 \

9
cfg.mk
View File

@ -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:

View File

@ -1095,7 +1095,7 @@ pciWaitForDeviceCleanup(pciDevice *dev, const char *matcher)
}
}
fclose(fp);
VIR_FORCE_FCLOSE(fp);
return ret;
}