]> xenbits.xensource.com Git - libvirt.git/commitdiff
enforce sane readdir usage
authorEric Blake <eblake@redhat.com>
Mon, 21 Apr 2014 22:33:15 +0000 (16:33 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 28 Apr 2014 23:52:46 +0000 (17:52 -0600)
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 <eblake@redhat.com>
cfg.mk
src/util/virfile.c

diff --git a/cfg.mk b/cfg.mk
index 8a444d646ccb3019f6ec6d5e9f11ca1ca01a557a..3f4bba07f5441730236a3a3ff8bf40d9d6c238be 100644 (file)
--- 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'                                 \
index bb1e7ba7bb602b65bbd3982e0abb5f34043d52e7..f75f0c89f0ff2e900269699e64b9a9c4699c92be 100644 (file)
@@ -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'"),