]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
strcompose: NULL must always be cast when passed to a variadic function
authorGarrett Wollman <wollman@csail.mit.edu>
Sat, 21 Jul 2012 05:35:15 +0000 (01:35 -0400)
committerDerrick Brashear <shadow@dementix.org>
Sun, 22 Jul 2012 12:22:08 +0000 (05:22 -0700)
The C standard allows NULL to be defined as a bare "0", which will
be passed to variadic functions as an int.  If the function expects
a pointer type, demons fly out of your nose.  strcompose() is such
a function, so make sure that all of its callers cast NULL appropriately.
(None of them did.)  This may be an opportune time to change all of
the callers to spell it opr_strcompose() as well, and avoid using a
reserved identifier, but this change does not do so.

Change-Id: Ia9007a48102da4d0a85a48b41a44e83102304b49
Reviewed-on: http://gerrit.openafs.org/7805
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/auth/cellconfig.c
src/auth/userok.c
src/auth/writeconfig.c
src/bozo/fsbnodeops.c
src/butc/tcmain.c
src/kauth/kaserver.c
src/ptserver/testpt.c
src/util/dirpath.c
src/vol/daemon_com.c

index e3f6af6a0e88bcce2de739a757b7da8190e88cf8..b0f7d3973b20b81ec1bc415adb6dc6e6bd1aa5dd 100644 (file)
@@ -509,7 +509,8 @@ GetCellUnix(struct afsconf_dir *adir)
     char *start, *p;
     afsconf_FILE *fp;
 
-    strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE, NULL);
+    strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE,
+       (char *)NULL);
     fp = fopen(tbuffer, "r");
     if (fp == 0) {
        return -1;
@@ -774,7 +775,8 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
 #endif /* AFS_NT40_ENV */
 
     /* Read in the alias list */
-    strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLALIAS_FILE, NULL);
+    strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLALIAS_FILE,
+       (char *)NULL);
 
     tf = fopen(tbuffer, "r");
     while (tf) {
index 29178c3328eaa05856a8d677d927922fe3cd6334..3c3926af85bb98aca4b5001585e646441942f48b 100644 (file)
@@ -43,8 +43,7 @@ static void
 UserListFileName(struct afsconf_dir *adir,
                 char *buffer, size_t len)
 {
-    strcompose(buffer, len, adir->name, "/",
-              AFSDIR_ULIST_FILE, NULL);
+    strcompose(buffer, len, adir->name, "/", AFSDIR_ULIST_FILE, (char *)NULL);
 }
 
 #if !defined(UKERNEL)
index 771e0fc19a2c343c4a1b7d6fce35634a16558674..9d8d479cad69b76e32076cbcc355fd35e2d83078 100644 (file)
@@ -88,7 +88,7 @@ afsconf_SetExtendedCellInfo(struct afsconf_dir *adir,
 
     LOCK_GLOBAL_MUTEX;
     /* write ThisCell file */
-    strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, NULL);
+    strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, (char *)NULL);
 
     fd = open(tbuffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
     if (fd < 0) {
@@ -115,7 +115,7 @@ afsconf_SetExtendedCellInfo(struct afsconf_dir *adir,
     }
 
     /* write CellServDB */
-    strcompose(tbuffer, 1024, apath, "/", AFSDIR_CELLSERVDB_FILE, NULL);
+    strcompose(tbuffer, 1024, apath, "/", AFSDIR_CELLSERVDB_FILE, (char *)NULL);
     tf = fopen(tbuffer, "w");
     if (!tf) {
        UNLOCK_GLOBAL_MUTEX;
index 4c23e940632a3e3074a2b6119a96ecdf92702fd5..8e0717a37e642039e211af43afad2c4e480eb6c2 100644 (file)
@@ -291,7 +291,7 @@ SetSalFlag(struct fsbnode *abnode, int aflag)
     if (abnode->salsrvcmd == NULL) {
        abnode->needsSalvage = aflag;
        strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
-                  SALFILE, abnode->b.name, NULL);
+                  SALFILE, abnode->b.name, (char *)NULL);
        if (aflag) {
            fd = open(tbuffer, O_CREAT | O_TRUNC | O_RDWR, 0666);
            close(fd);
@@ -313,7 +313,7 @@ RestoreSalFlag(struct fsbnode *abnode)
        abnode->needsSalvage = 0;
     } else {
        strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
-                  SALFILE, abnode->b.name, NULL);
+                  SALFILE, abnode->b.name, (char *)NULL);
        if (access(tbuffer, 0) == 0) {
            /* file exists, so need to salvage */
            abnode->needsSalvage = 1;
index d425cee9e44a998a84473a1eceac69303084a1d6..088def14faf853e4e666cd744cd34017ff023972 100644 (file)
@@ -1194,11 +1194,11 @@ main(int argc, char **argv)
 
     /* setup the file paths */
     strcompose(eFile, AFSDIR_PATH_MAX, AFSDIR_SERVER_BACKUP_DIRPATH, "/",
-              TE_PREFIX, NULL);
+              TE_PREFIX, (char *)NULL);
     strcompose(lFile, AFSDIR_PATH_MAX, AFSDIR_SERVER_BACKUP_DIRPATH, "/",
-              TL_PREFIX, NULL);
+              TL_PREFIX, (char *)NULL);
     strcompose(pFile, AFSDIR_PATH_MAX, AFSDIR_SERVER_BACKUP_DIRPATH, "/",
-              CFG_PREFIX, NULL);
+              CFG_PREFIX, (char *)NULL);
     strcpy(tapeConfigFile, AFSDIR_SERVER_TAPECONFIG_FILEPATH);
 
     /* special case "no args" case since cmd_dispatch gives help message
index e659f1f21391a2a2278ea31643f0908aad547944..146239cb7de1471ea1beeae8ab82d95f739d184b 100644 (file)
@@ -226,7 +226,7 @@ main(int argc, char *argv[])
     cellservdb = AFSDIR_SERVER_ETC_DIRPATH;
     dbpath = AFSDIR_SERVER_KADB_FILEPATH;
     strcompose(default_lclpath, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH,
-              "/", AFSDIR_KADB_FILE, NULL);
+              "/", AFSDIR_KADB_FILE, (char *)NULL);
     lclpath = default_lclpath;
 
     debugOutput = 0;
index 503149df9247ee12c851ea1eff37bf580f0f20a3..766b8c57ae528422140abd533e9275499d4bb049 100644 (file)
@@ -988,7 +988,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
        }
 
        strcompose(tmp_conf_file, 128, tmp_conf_dir, "/",
-                  AFSDIR_CELLSERVDB_FILE, NULL);
+                  AFSDIR_CELLSERVDB_FILE, (char *)NULL);
        f = fopen(tmp_conf_file, "w");
        if (f == 0) {
          cantcreate:
@@ -1011,7 +1011,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
        }
 
        strcompose(tmp_cell_file, 128, tmp_conf_dir, "/",
-                  AFSDIR_THISCELL_FILE, NULL);
+                  AFSDIR_THISCELL_FILE, (char *)NULL);
        f = fopen(tmp_cell_file, "w");
        if (f == 0)
            goto cantcreate;
@@ -1020,7 +1020,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
            goto cantclose;
 
        strcompose(tmp_noauth_file, 128, tmp_conf_dir, "/",
-                  AFSDIR_NOAUTH_FILE, NULL);
+                  AFSDIR_NOAUTH_FILE, (char *)NULL);
        if (noAuth) {
            code = creat(tmp_noauth_file, 0777);
            if (code && (errno != EEXIST))
index 3e76824e0b42a6a801ea3d41a1736834fbf75b18..776c7fd37ba1e521645caac8e05484bb331e5d39 100644 (file)
@@ -58,16 +58,16 @@ static void initDirPathArray(void);
 /* Additional macros for ease of use */
 /* buf is expected to be atleast AFS_PATH_MAX bytes long */
 #define AFSDIR_SERVER_DIRPATH(buf, dir)  \
-            (void) strcompose(buf, AFSDIR_PATH_MAX, serverPrefix, dir, NULL)
+            (void) strcompose(buf, AFSDIR_PATH_MAX, serverPrefix, dir, (char *)NULL)
 
 #define AFSDIR_SERVER_FILEPATH(buf, dir, file)  \
-            (void) strcompose(buf, AFSDIR_PATH_MAX, serverPrefix, dir, "/", file,  NULL)
+            (void) strcompose(buf, AFSDIR_PATH_MAX, serverPrefix, dir, "/", file,  (char *)NULL)
 
 #define AFSDIR_CLIENT_DIRPATH(buf, dir)  \
-            (void) strcompose(buf, AFSDIR_PATH_MAX, clientPrefix, dir, NULL)
+            (void) strcompose(buf, AFSDIR_PATH_MAX, clientPrefix, dir, (char *)NULL)
 
 #define AFSDIR_CLIENT_FILEPATH(buf, dir, file)  \
-            (void) strcompose(buf, AFSDIR_PATH_MAX,  clientPrefix, dir, "/", file,  NULL)
+            (void) strcompose(buf, AFSDIR_PATH_MAX,  clientPrefix, dir, "/", file,  (char *)NULL)
 
 
 /* initAFSDirPath() -- External users call this function to initialize
index 0ae1e2b628c7b764987d12be3d38f356075c08a5..60fc7d9cb6215d9fb99ee846b00013645d322ab3 100644 (file)
@@ -88,7 +88,7 @@ SYNC_getAddr(SYNC_endpoint_t * endpoint, SYNC_sockaddr_t * addr)
 
 #ifdef USE_UNIX_SOCKETS
     strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
-               endpoint->un, NULL);
+               endpoint->un, (char *)NULL);
     addr->sun_family = AF_UNIX;
     strncpy(addr->sun_path, tbuffer, (sizeof(struct sockaddr_un) - sizeof(short)));
 #else  /* !USE_UNIX_SOCKETS */