Add format checking to the Log, LogError and LogDebug functions.
Fix the resulting type errors. One of these in particular is a
signficant bug, where we would try to print a hash table pointer
as a string.
Change-Id: I02d7bcd7ce63583d24dda4da40288af51a516583
Reviewed-on: http://gerrit.openafs.org/2445
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
/* server.c */
-void Log(char *fmt, ... );
-void LogError(long code, char *fmt, ... );
-void LogDebug(int level, char *fmt, ... );
+void Log(char *fmt, ... )
+ AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
+void LogError(long code, char *fmt, ... )
+ AFS_ATTRIBUTE_FORMAT(__printf__, 2, 3);
+void LogDebug(int level, char *fmt, ... )
+ AFS_ATTRIBUTE_FORMAT(__printf__, 2, 3);
/* struct_ops.c */
}
code = ubik_Read(ut, buff, len);
if (code) {
- LogError(code, "dbread: ubik_Read pos %d, buff %d, len %d\n", pos,
- buff, len);
+ LogError(code, "dbread: ubik_Read pos %d, buff %"AFS_PTR_FMT
+ ", len %d\n", pos, buff, len);
ERROR(code);
}
}
code = ubik_Read(ut, buff, len);
if (code) {
- LogError(code, "cdbread: ubik_Read pos 0x%x, buff %d, len %d\n", pos,
- buff, len);
+ LogError(code, "cdbread: ubik_Read pos 0x%x, buff %"AFS_PTR_FMT
+ ", len %d\n", pos, buff, len);
ERROR(code);
}
*(afs_int32 *) s = 1; /* make sure structure is not free */
*saP = a + ((char *)bs - (char *)&b);
- LogDebug(3, "allocated at %d, block at %d, offset %d\n", *saP, a,
- ((char *)bs - (char *)&b));
+ LogDebug(3, "allocated at %d, block at %d, offset %ld\n", *saP, a,
+ (long int)((char *)bs - (char *)&b));
/* caller must write back at least first word of structure */
return 0;
}
htonl(ea));
if (code)
return BUDB_IO;
- LogDebug(5, "Hashin: set %d to %d\n", &block->b.bucket[bo], htonl(ea));
+ LogDebug(5, "Hashin: set %"AFS_PTR_FMT" to %d\n",
+ &block->b.bucket[bo], htonl(ea));
code =
set_word_addr(ut, 0, &db.h, &ht->entries,
char *textPtr;
afs_int32 code;
- LogDebug(5, "GetText: type %d, offset %d, nextOffset %d, maxLength %d\n",
- textType, offset, nextOffset, maxLength);
+ LogDebug(5, "GetText: type %d, offset %d, nextOffset %"AFS_PTR_FMT
+ ", maxLength %d\n", textType, offset, nextOffset, maxLength);
if (callPermitted(call) == 0) {
code = BUDB_NOTPERMITTED;
if (eval)
ERROR(eval);
- LogDebug(4, "volume Info for %s placed at %d\n", db.volName, via);
+ LogDebug(4, "volume Info for %s placed at %d\n", volP->name, via);
}
else if (!VolInfoMatch(volP, viP)) { /* Not the head volinfo struct */