From 8bfce8f2787a512cfb24e3360435600abe5904d0 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Thu, 20 Dec 2012 15:54:57 -0500 Subject: [PATCH] vol: use defines for header name length instead of randomly hardcoding numbers in several places, use macros Change-Id: I153cbe74d0d297496fb39449c4a71ec81d5637c5 Reviewed-on: http://gerrit.openafs.org/8806 Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/vol/voldefs.h | 4 +++- src/volser/volprocs.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vol/voldefs.h b/src/vol/voldefs.h index 2191382a61..6341191589 100644 --- a/src/vol/voldefs.h +++ b/src/vol/voldefs.h @@ -39,6 +39,8 @@ /* maximum numbe of Vice partitions */ #define VOLMAXPARTS 255 +#define VFORMATDIGITS 10 + /* All volumes will have a volume header name in this format */ #if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) /* Note that must have been included before we get here... */ @@ -48,7 +50,7 @@ #define VFORMAT "V%010lu.vol" #define VHDREXT ".vol" #endif -#define VHDRNAMELEN (11 + sizeof(VHDREXT) - 1) /* must match VFORMAT */ +#define VHDRNAMELEN (VFORMATDIGITS + 1 + sizeof(VHDREXT) - 1) /* must match VFORMAT */ #define VMAXPATHLEN 64 /* Maximum length (including null) of a volume * external path name */ diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c index eb003a4608..c9ad3d482f 100644 --- a/src/volser/volprocs.c +++ b/src/volser/volprocs.c @@ -1924,7 +1924,7 @@ GetNextVol(DIR *dirp, char *volname, afs_uint32 *volid) while ((dp = readdir(dirp)) != NULL) { /* could be optimized on platforms with dp->d_namlen */ if (dp->d_name[0] == 'V' && strlen(dp->d_name) == VHDRNAMELEN - && strcmp(&(dp->d_name[11]), VHDREXT) == 0) { + && strcmp(&(dp->d_name[VFORMATDIGITS + 1]), VHDREXT) == 0) { *volid = VolumeNumber(dp->d_name); strcpy(volname, dp->d_name); return 1;