提交 f1fe9671 编写于 作者: E Eric Blake

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.
上级 d8b36749
^docs/.*
^HACKING$
^src/util/files.c$
......@@ -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 \
......
......@@ -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:
......
......@@ -1095,7 +1095,7 @@ pciWaitForDeviceCleanup(pciDevice *dev, const char *matcher)
}
}
fclose(fp);
VIR_FORCE_FCLOSE(fp);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册