From e39d6ca55af79b917e459a09893606e79ba50375 Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Sat, 21 Jul 2012 01:35:15 -0400 Subject: [PATCH] strcompose: NULL must always be cast when passed to a variadic function 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 Reviewed-by: Derrick Brashear --- src/auth/cellconfig.c | 6 ++++-- src/auth/userok.c | 3 +-- src/auth/writeconfig.c | 4 ++-- src/bozo/fsbnodeops.c | 4 ++-- src/butc/tcmain.c | 6 +++--- src/kauth/kaserver.c | 2 +- src/ptserver/testpt.c | 6 +++--- src/util/dirpath.c | 8 ++++---- src/vol/daemon_com.c | 2 +- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c index e3f6af6a0..b0f7d3973 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -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) { diff --git a/src/auth/userok.c b/src/auth/userok.c index 29178c332..3c3926af8 100644 --- a/src/auth/userok.c +++ b/src/auth/userok.c @@ -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) diff --git a/src/auth/writeconfig.c b/src/auth/writeconfig.c index 771e0fc19..9d8d479ca 100644 --- a/src/auth/writeconfig.c +++ b/src/auth/writeconfig.c @@ -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; diff --git a/src/bozo/fsbnodeops.c b/src/bozo/fsbnodeops.c index 4c23e9406..8e0717a37 100644 --- a/src/bozo/fsbnodeops.c +++ b/src/bozo/fsbnodeops.c @@ -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; diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c index d425cee9e..088def14f 100644 --- a/src/butc/tcmain.c +++ b/src/butc/tcmain.c @@ -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 diff --git a/src/kauth/kaserver.c b/src/kauth/kaserver.c index e659f1f21..146239cb7 100644 --- a/src/kauth/kaserver.c +++ b/src/kauth/kaserver.c @@ -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; diff --git a/src/ptserver/testpt.c b/src/ptserver/testpt.c index 503149df9..766b8c57a 100644 --- a/src/ptserver/testpt.c +++ b/src/ptserver/testpt.c @@ -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)) diff --git a/src/util/dirpath.c b/src/util/dirpath.c index 3e76824e0..776c7fd37 100644 --- a/src/util/dirpath.c +++ b/src/util/dirpath.c @@ -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 diff --git a/src/vol/daemon_com.c b/src/vol/daemon_com.c index 0ae1e2b62..60fc7d9cb 100644 --- a/src/vol/daemon_com.c +++ b/src/vol/daemon_com.c @@ -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 */ -- 2.39.5