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 e3f6af6..b0f7d39 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 29178c3..3c3926a 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 771e0fc..9d8d479 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 4c23e94..8e0717a 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 d425cee..088def1 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 e659f1f..146239c 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 503149d..766b8c5 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 3e76824..776c7fd 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 0ae1e2b..60fc7d9 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 */