]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
dir: Add printf format checks to log
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Sat, 17 Jul 2010 17:23:30 +0000 (18:23 +0100)
committerDerrick Brashear <shadow@dementia.org>
Sun, 18 Jul 2010 15:15:58 +0000 (08:15 -0700)
salvage.c uses the Log() function defined by vol/common.c. At the
moment, this isn't defined in a way that we can easily grab its prototype,
so the code has an extern definition at the beginning. For now, just add
format checks to this definition.

Fix all of the fallout from this - we were casting to intptr, and
printing with %x - use AFS_PTR_FMT as nature intended.

Change-Id: I2110ebddbe207c307fcad00ab89e5818824a644d
Reviewed-on: http://gerrit.openafs.org/2446
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/dir/salvage.c

index 02830862c81f61c704a1fbf684f2e0ed1e3c998a..fc6e521a9c7b0f5a9ac5c6c23e4a5dbf260daf60 100644 (file)
@@ -33,7 +33,8 @@
 
 #include "dir.h"
 /* Defined in vol/vol-salvage.c */
-extern void Log(const char *format, ...);
+extern void Log(const char *format, ...)
+    AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
 /* Defined in vol/physio.c */
 extern void Die(char *);
     
@@ -299,8 +300,8 @@ DirOK(void *file)
 
            /* A null name is no good */
            if (ep->name[0] == '\000') {
-               printf("Dir entry %x in chain %d has bogus (null) name.\n",
-                      (intptr_t)ep, i);
+               printf("Dir entry %"AFS_PTR_FMT
+                      " in chain %d has bogus (null) name.\n", ep, i);
                DRelease(ep, 0);
                DRelease(dhp, 0);
                return 0;
@@ -308,8 +309,8 @@ DirOK(void *file)
 
            /* The entry flag better be FFIRST */
            if (ep->flag != FFIRST) {
-               printf("Dir entry %x in chain %d has bogus flag field.\n", (intptr_t)ep,
-                      i);
+               printf("Dir entry %"AFS_PTR_FMT
+                      " in chain %d has bogus flag field.\n", ep, i);
                DRelease(ep, 0);
                DRelease(dhp, 0);
                return 0;
@@ -318,8 +319,8 @@ DirOK(void *file)
            /* Check the size of the name */
            j = strlen(ep->name);
            if (j >= MAXENAME) {        /* MAXENAME counts the null */
-               printf("Dir entry %x in chain %d has too-long name.\n", (intptr_t)ep,
-                      i);
+               printf("Dir entry %"AFS_PTR_FMT
+                      " in chain %d has too-long name.\n", ep, i);
                DRelease(ep, 0);
                DRelease(dhp, 0);
                return 0;
@@ -335,9 +336,9 @@ DirOK(void *file)
 
            /* Hash the name and make sure it is in the correct name hash */
            if ((j = DirHash(ep->name)) != i) {
-               printf
-                   ("Dir entry %x should be in hash bucket %d but IS in %d.\n",
-                    (intptr_t)ep, j, i);
+               printf("Dir entry %"AFS_PTR_FMT
+                      " should be in hash bucket %d but IS in %d.\n",
+                      ep, j, i);
                DRelease(ep, 0);
                DRelease(dhp, 0);
                return 0;
@@ -349,8 +350,9 @@ DirOK(void *file)
                    havedot = 1;
                } else {
                    printf
-                       ("Dir entry %x, index 13 has name '%s' should be '.'\n",
-                        (intptr_t)ep, ep->name);
+                       ("Dir entry %"AFS_PTR_FMT
+                        ", index 13 has name '%s' should be '.'\n",
+                        ep, ep->name);
                    DRelease(ep, 0);
                    DRelease(dhp, 0);
                    return 0;
@@ -363,8 +365,9 @@ DirOK(void *file)
                    havedotdot = 1;
                } else {
                    printf
-                       ("Dir entry %x, index 14 has name '%s' should be '..'\n",
-                        (intptr_t)ep, ep->name);
+                       ("Dir entry %"AFS_PTR_FMT
+                        ", index 14 has name '%s' should be '..'\n",
+                        ep, ep->name);
                    DRelease(ep, 0);
                    DRelease(dhp, 0);
                    return 0;