* 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.
--- /dev/null
+^docs/.*
+^HACKING$
+^src/util/files.c$
.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 \
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:
}
}
- fclose(fp);
+ VIR_FORCE_FCLOSE(fp);
return ret;
}