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 <rra@stanford.edu>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Russ Allbery 2009-12-30 16:22:37 -08:00 committed by Derrick Brashear
parent 1526593621
commit 4d6d786668
5 changed files with 24 additions and 11 deletions

View File

@ -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)];
}

View File

@ -34,6 +34,7 @@
#ifdef SUPERGROUPS
#include <errno.h>
#include <string.h>
#include "map.h"
#ifdef STDLIB_HAS_MALLOC_PROTOS
#include <stdlib.h>

View File

@ -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;

View File

@ -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);

View File

@ -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;