From eae00fb59a8e126d1cdc942c46e26c5b43c2be8b Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 21 Apr 2014 16:33:15 -0600 Subject: [PATCH] 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: Eric Blake --- cfg.mk | 6 ++++++ src/util/virfile.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cfg.mk b/cfg.mk index 8a444d646c..3f4bba07f5 100644 --- a/cfg.mk +++ b/cfg.mk @@ -421,6 +421,12 @@ sc_prohibit_gethostname: halt='use virGetHostname, not gethostname' \ $(_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: @prohibit='gettext_noop *\(' \ halt='use N_, not gettext_noop' \ diff --git a/src/util/virfile.c b/src/util/virfile.c index bb1e7ba7bb..f75f0c89f0 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2401,7 +2401,7 @@ virDirCreate(const char *path ATTRIBUTE_UNUSED, int virDirRead(DIR *dirp, struct dirent **ent, const char *name) { errno = 0; - *ent = readdir(dirp); + *ent = readdir(dirp); /* exempt from syntax-check */ if (!*ent && errno) { if (name) virReportSystemError(errno, _("Unable to read directory '%s'"), -- 2.47.2