From 4d6d7866689a2c005a055c580b8a54d7c9412386 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Wed, 30 Dec 2009 16:22:37 -0800 Subject: [PATCH] Remove warnings from supergroups code on x86 Prototype functions where necessary, remove unused variables, fix mismatches of data types (char * != void *), initialize variables the compiler can't tell are initialized, compare integers against 0 and not NULL, and wrap assignments used as conditions in an explicit comparison. This removes all warnings that fail --enable-checking on x86 with --enable-supergroups. 64-bit will still have warnings. Change-Id: I5ab6e317a280bea29cb44b97f2805a00e387577f Reviewed-on: http://gerrit.openafs.org/1050 Tested-by: Russ Allbery Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear --- src/ptserver/db_verify.c | 7 +++---- src/ptserver/map.c | 1 + src/ptserver/ptprocs.c | 2 +- src/ptserver/ptprototypes.h | 11 +++++++++++ src/ptserver/ptutils.c | 14 ++++++++------ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/ptserver/db_verify.c b/src/ptserver/db_verify.c index abedd48fc3..2ea33f933c 100644 --- a/src/ptserver/db_verify.c +++ b/src/ptserver/db_verify.c @@ -402,7 +402,7 @@ WalkNextChain(char map[], /* one byte per db entry */ int noErrors = 1; int length; /* length of chain */ #if defined(SUPERGROUPS) - int sgcount; /* number of sgentrys */ + int sgcount = 0; /* number of sgentrys */ afs_int32 sghead; #define g (((struct prentryg *)e)) #endif @@ -412,7 +412,6 @@ WalkNextChain(char map[], /* one byte per db entry */ eid = ntohl(e->id); bit = MAP_CONT; #if defined(SUPERGROUPS) - sgcount = 0; sghead = ntohl(g->next); #endif for (i = 0; i < PRSIZE; i++) { @@ -1524,7 +1523,7 @@ inccount(struct idused **idmapp, int id) fprintf(stderr, "IDCOUNT must be power of 2!\n"); exit(1); } - while (idmap = *idmapp) { + while ((idmap = *idmapp) != NULL) { if (idmap->idstart == (id & ~(IDCOUNT - 1))) break; idmapp = &idmap->idnext; @@ -1552,7 +1551,7 @@ idcount(struct idused **idmapp, int id) fprintf(stderr, "IDCOUNT must be power of 2!\n"); exit(1); } - while (idmap = *idmapp) { + while ((idmap = *idmapp) != NULL) { if (idmap->idstart == (id & ~(IDCOUNT - 1))) { return idmap->idcount[id & (IDCOUNT - 1)]; } diff --git a/src/ptserver/map.c b/src/ptserver/map.c index b28a479c26..eb06194e67 100644 --- a/src/ptserver/map.c +++ b/src/ptserver/map.c @@ -34,6 +34,7 @@ #ifdef SUPERGROUPS #include +#include #include "map.h" #ifdef STDLIB_HAS_MALLOC_PROTOS #include diff --git a/src/ptserver/ptprocs.c b/src/ptserver/ptprocs.c index 3693862ebd..e67da23155 100644 --- a/src/ptserver/ptprocs.c +++ b/src/ptserver/ptprocs.c @@ -855,7 +855,7 @@ Delete(struct rx_call *call, afs_int32 aid, afs_int32 *cid) { struct prentryg *tentryg = (struct prentryg *)&tentry; nptr = tentryg->nextsg; - while (nptr != NULL) { + while (nptr != 0) { struct contentry centry; int i; diff --git a/src/ptserver/ptprototypes.h b/src/ptserver/ptprototypes.h index 4e0a4cae1e..b36c4e7e0f 100644 --- a/src/ptserver/ptprototypes.h +++ b/src/ptserver/ptprototypes.h @@ -16,6 +16,17 @@ extern afs_int32 IsAMemberOfSG(struct ubik_trans *at, afs_int32 aid, afs_int32 gid, afs_int32 depth) ; #endif /* SUPERGROUPS */ +/* ptutils.c */ +#ifdef SUPERGROUPS +extern afs_int32 AddToSGEntry(struct ubik_trans *tt, struct prentry *entry, + afs_int32 loc, afs_int32 aid); +extern afs_int32 GetSGList(struct ubik_trans *at, struct prentry *tentry, + prlist *alist); +extern afs_int32 RemoveFromSGEntry(struct ubik_trans *at, afs_int32 aid, + afs_int32 bid); +extern void pt_hook_write(void); +#endif + extern afs_int32 NameHash(register unsigned char *aname); extern afs_int32 pr_Write(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos, void *buff, afs_int32 len); diff --git a/src/ptserver/ptutils.c b/src/ptserver/ptutils.c index 87d24a7ba2..9006412972 100644 --- a/src/ptserver/ptutils.c +++ b/src/ptserver/ptutils.c @@ -84,10 +84,11 @@ struct map *sg_found; * so we can always tell if we're writing a group record. */ -int (*pt_save_dbase_write) (); +int (*pt_save_dbase_write)(struct ubik_dbase *, afs_int32, void *, afs_int32, + afs_int32); int -pt_mywrite(struct ubik_dbase *tdb, afs_int32 fno, char *bp, afs_int32 pos, afs_int32 count) +pt_mywrite(struct ubik_dbase *tdb, afs_int32 fno, void *bp, afs_int32 pos, afs_int32 count) { afs_uint32 headersize = ntohl(cheader.headerSize); @@ -163,7 +164,7 @@ pt_mywrite(struct ubik_dbase *tdb, afs_int32 fno, char *bp, afs_int32 pos, afs_i */ void -pt_hook_write() +pt_hook_write(void) { extern struct ubik_dbase *ubik_dbase; if (ubik_dbase->write != pt_mywrite) { @@ -1126,7 +1127,7 @@ AddToSGEntry(struct ubik_trans *tt, struct prentry *entry, afs_int32 loc, afs_in afs_int32 nptr; afs_int32 last; /* addr of last cont. block */ afs_int32 first = 0; - afs_int32 cloc; + afs_int32 cloc = 0; afs_int32 slot = -1; if (entry->id == aid) @@ -1853,11 +1854,12 @@ afs_int32 ChangeEntry(struct ubik_trans *at, afs_int32 aid, afs_int32 cid, char *name, afs_int32 oid, afs_int32 newid) { afs_int32 code; - afs_int32 i, nptr, pos; + afs_int32 i, pos; #if defined(SUPERGROUPS) afs_int32 nextpos; +#else + afs_int32 nptr; #endif - struct contentry centry; struct prentry tentry, tent; afs_int32 loc; afs_int32 oldowner;