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

enforce sane readdir usage

Now that all clients have been adjusted, ensure that no future
misuse of readdir is introduced into the code base.

* cfg.mk (sc_prohibit_readdir): New rule.
* src/util/virfile.c (virDirRead): Exempt the wrapper.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 a4315234
...@@ -421,6 +421,12 @@ sc_prohibit_gethostname: ...@@ -421,6 +421,12 @@ sc_prohibit_gethostname:
halt='use virGetHostname, not gethostname' \ halt='use virGetHostname, not gethostname' \
$(_sc_search_regexp) $(_sc_search_regexp)
sc_prohibit_readdir:
@prohibit='\breaddir *\(' \
exclude='exempt from syntax-check' \
halt='use virDirRead, not readdir' \
$(_sc_search_regexp)
sc_prohibit_gettext_noop: sc_prohibit_gettext_noop:
@prohibit='gettext_noop *\(' \ @prohibit='gettext_noop *\(' \
halt='use N_, not gettext_noop' \ halt='use N_, not gettext_noop' \
......
...@@ -2401,7 +2401,7 @@ virDirCreate(const char *path ATTRIBUTE_UNUSED, ...@@ -2401,7 +2401,7 @@ virDirCreate(const char *path ATTRIBUTE_UNUSED,
int virDirRead(DIR *dirp, struct dirent **ent, const char *name) int virDirRead(DIR *dirp, struct dirent **ent, const char *name)
{ {
errno = 0; errno = 0;
*ent = readdir(dirp); *ent = readdir(dirp); /* exempt from syntax-check */
if (!*ent && errno) { if (!*ent && errno) {
if (name) if (name)
virReportSystemError(errno, _("Unable to read directory '%s'"), virReportSystemError(errno, _("Unable to read directory '%s'"),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册