vol: use defines for header name length
authorDerrick Brashear <shadow@your-file-system.com>
Thu, 20 Dec 2012 20:54:57 +0000 (15:54 -0500)
committerDerrick Brashear <shadow@your-file-system.com>
Thu, 27 Dec 2012 19:19:31 +0000 (11:19 -0800)
instead of randomly hardcoding numbers in several places,
use macros

Change-Id: I153cbe74d0d297496fb39449c4a71ec81d5637c5
Reviewed-on: http://gerrit.openafs.org/8806
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/vol/voldefs.h
src/volser/volprocs.c

index 2191382..6341191 100644 (file)
@@ -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 <afs/param.h> 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 */
 
index eb003a4..c9ad3d4 100644 (file)
@@ -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;