From 19f0da1e44c6ac5acd22f8a2b1d9095d568d216e Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Thu, 19 Nov 2009 18:29:08 -0500 Subject: [PATCH] Warning fixes - key handling Various warning fixes related mostly to the different types used to handle keys. This should clear most of the remaining warnings in this area. The technique of inline converter helpers is extended to cover a few more cases. README.WARNINGS is adjusted to reflect the current status. Fixes: - bos: define and use an inline converter from a ktc key to a bozo key - bos.c and bos_utils.c should no longer have warnings - adjust Makefile - define a ktc key to char * converter and use it in a few places - define kas key to bozo key ptr converter and use it in a few places (afs_bosAdmin) - cast a few arguments to ka_StringToKey which expects non-const pointers Change-Id: I1c19869ac232d78209126d4eeeb11af8bcb95815 Reviewed-on: http://gerrit.openafs.org/860 Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- README.WARNINGS | 10 +++------- src/bozo/Makefile.in | 4 ++-- src/bozo/bos.c | 9 +++++---- src/bozo/bos_util.c | 4 ++-- src/bozo/bosprototypes.h | 7 +++++++ src/libadmin/bos/afs_bosAdmin.c | 4 ++-- src/libadmin/bos/afs_bosAdmin.h | 5 +++++ src/libadmin/kas/afs_kasAdmin.c | 2 +- src/rxkad/Makefile.in | 2 +- src/rxkad/rxkad_prototypes.h | 5 +++++ src/uss/uss_kauth.c | 4 ++-- 11 files changed, 35 insertions(+), 21 deletions(-) diff --git a/README.WARNINGS b/README.WARNINGS index 39c39b1174..923d89cec4 100644 --- a/README.WARNINGS +++ b/README.WARNINGS @@ -46,8 +46,6 @@ afsd/afsd.c : deprecated : daemon() marked as deprecated on Darwin : all : call_syscall missing prototype auth/ktc.c : all (ukernel) : call_syscall doesn't have a prototype bozo/bosserver.c : deprecated : daemon() marked as deprecated on Darwin -bozo/bos.c : all : DES key types & string consts -bozo/bos_util.c : all : DES key types bucoord/ubik_db_if.c : strict-proto : Ubik_Call bucoord/commands.c : all : Ubik_Call : signed vs unsigned for dates @@ -55,13 +53,11 @@ butc/tcmain.c : all : prototypes butc/tcudbprocs.c : all : ubik_Call kauth/admin_tools.c : all : ubik_Call nonsense kauth/authclient.c : strict-proto : ubik_Call nonsense -libadmin/bos/afs_bosAdmin.c: all : DES keys, time types, and const -libadmin/kas/afs_kasAdmin.c: all : Ubik_Call nonsense, DES keys +libadmin/bos/afs_bosAdmin.c: all : time types, and const +libadmin/kas/afs_kasAdmin.c: all : Ubik_Call nonsense libadmin/samples/rxstat_query_peer.c : all : util_RPCStatsStateGet types libadmin/samples/rxstat_query_process.c : all : util_RPCStatsStateGet types libadmin/test/client.c : all : util_RPCStatsStateGet types -rxkad/rxkad_server.c : all : Des key nonsense - maybe fixed (no errors in pthread) -rxkad/ticket5.c : all : CRC functions - maybe fixed (no errors in normal & pthread) rx/rx.c : all (pthread) : rxkad_global_stats_init not proto'd rx/xdr_rx.c : all (ukernel) : Prototypes don't match due to AFS_XDR_T not being used in the xdr header @@ -70,7 +66,7 @@ ubik/beacon.c : all : Ubik uses signed/unsigned fix will require API changes. ubik/ubikclient.c : strict-protos : ubik_Call uss/uss_vol.c : all Format issues -uss/uss_kauth.c : all : Des keys, ubik_Call +uss/uss_kauth.c : all : ubik_Call viced/fsprobe.c : all : ubik_Call vol/salvager.c : all : consts & undefined variable from header - maybe fixed! volser/vol-dump.c : format : afs_sfsize_t diff --git a/src/bozo/Makefile.in b/src/bozo/Makefile.in index 286389b30a..14bb2794d9 100644 --- a/src/bozo/Makefile.in +++ b/src/bozo/Makefile.in @@ -91,13 +91,13 @@ bnode.o: bnode.c ${INCLS} bosoprocs.o: bosoprocs.c ${INCLS} bos.o: bos.c ${INCLS} AFS_component_version_number.o - $(CC) $(CFLAGS) @CFLAGS_NOERROR@ -c $< + $(CC) $(CFLAGS) -c $< bos: bos.o $(LIBS) libbos.a ${CC} ${CFLAGS} -o bos bos.o libbos.a $(LIBS) ${XLIBS} bos_util.o: bos_util.c ${INCLS} AFS_component_version_number.o ${TOP_INCDIR}/afs/bnode.h - $(CC) $(CFLAGS) @CFLAGS_NOERROR@ -c $< + $(CC) $(CFLAGS) -c $< bos_util: bos_util.o $(LIBS) ${CC} ${CFLAGS} -o bos_util bos_util.o $(LIBS) ${XLIBS} diff --git a/src/bozo/bos.c b/src/bozo/bos.c index e7e7f3397a..fd79e4ff9d 100644 --- a/src/bozo/bos.c +++ b/src/bozo/bos.c @@ -53,6 +53,7 @@ static int DoStat(char *aname, register struct rx_connection *aconn, int aint32p, int firstTime); #include "bosint.h" +#include "bosprototypes.h" /* command offsets for bos salvage command */ #define MRAFS_OFFSET 10 @@ -906,7 +907,7 @@ AddKey(register struct cmd_syndesc *as, void *arock) ka_StringToKey(buf, tcell, &tkey); } tconn = GetConn(as, 1); - code = BOZO_AddKey(tconn, temp, &tkey); + code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey)); if (code) { printf("bos: failed to set key %d (%s)\n", temp, em(code)); exit(1); @@ -948,14 +949,14 @@ ListKeys(register struct cmd_syndesc *as, void *arock) tconn = GetConn(as, 1); everWorked = 0; for (i = 0;; i++) { - code = BOZO_ListKeys(tconn, i, &kvno, &tkey, &keyInfo); + code = BOZO_ListKeys(tconn, i, &kvno, ktc_to_bozoptr(&tkey), &keyInfo); if (code) break; everWorked = 1; /* first check if key is returned */ - if ((!ka_KeyIsZero(&tkey, sizeof(tkey))) && (as->parms[1].items)) { + if ((!ka_KeyIsZero(ktc_to_charptr(&tkey), sizeof(tkey))) && (as->parms[1].items)) { printf("key %d is '", kvno); - ka_PrintBytes(&tkey, sizeof(tkey)); + ka_PrintBytes(ktc_to_charptr(&tkey), sizeof(tkey)); printf("'\n"); } else { if (keyInfo.keyCheckSum == 0) /* shouldn't happen */ diff --git a/src/bozo/bos_util.c b/src/bozo/bos_util.c index 5cfb674ea5..e11dfb9895 100644 --- a/src/bozo/bos_util.c +++ b/src/bozo/bos_util.c @@ -91,7 +91,7 @@ main(int argc, char **argv) exit(1); } ka_StringToKey(buf, tcell, &tkey); - code = afsconf_AddKey(tdir, kvno, &tkey, 0); + code = afsconf_AddKey(tdir, kvno, ktc_to_charptr(&tkey), 0); if (code) { printf("bos_util: failed to set key, code %d.\n", code); exit(1); @@ -125,7 +125,7 @@ main(int argc, char **argv) exit(1); } des_string_to_key(buf, ktc_to_cblockptr(&tkey)); - code = afsconf_AddKey(tdir, kvno, &tkey, 0); + code = afsconf_AddKey(tdir, kvno, ktc_to_charptr(&tkey), 0); if (code) { printf("bos_util: failed to set key, code %d.\n", code); exit(1); diff --git a/src/bozo/bosprototypes.h b/src/bozo/bosprototypes.h index 5314c0cc8b..360bb7792c 100644 --- a/src/bozo/bosprototypes.h +++ b/src/bozo/bosprototypes.h @@ -10,6 +10,8 @@ #ifndef _BOSPROTOTYPES_H_ #define _BOSPROTOTYPES_H_ +#include + /* bnode.c */ int bnode_CoreName(struct bnode *abnode, char *acoreName, char *abuffer); int bnode_GetString(struct bnode *abnode, char *abuffer, afs_int32 alen); @@ -54,4 +56,9 @@ char *copystr(char *a); /* bosoprocs.c */ void *bozo_ShutdownAndExit(void *arock /* really int asignal */); +static_inline struct bozo_key * +ktc_to_bozoptr(struct ktc_encryptionKey *key) { + return (struct bozo_key *)key; +} + #endif diff --git a/src/libadmin/bos/afs_bosAdmin.c b/src/libadmin/bos/afs_bosAdmin.c index 44be450cbe..d80ed32b58 100644 --- a/src/libadmin/bos/afs_bosAdmin.c +++ b/src/libadmin/bos/afs_bosAdmin.c @@ -1941,7 +1941,7 @@ bos_KeyCreate(const void *serverHandle, int keyVersionNumber, goto fail_bos_KeyCreate; } - tst = BOZO_AddKey(b_handle->server_encrypt, keyVersionNumber, key); + tst = BOZO_AddKey(b_handle->server_encrypt, keyVersionNumber, kas_to_bozoptr(key)); if (tst == 0) { rc = 1; @@ -2020,7 +2020,7 @@ GetKeyRPC(void *rpc_specific, int slot, int *last_item, tst = BOZO_ListKeys(key->server, key->next++, - &key->key[slot].keyVersionNumber, &key->key[slot].key, + &key->key[slot].keyVersionNumber, kas_to_bozoptr(&key->key[slot].key), &keyInfo); diff --git a/src/libadmin/bos/afs_bosAdmin.h b/src/libadmin/bos/afs_bosAdmin.h index ddfb63c5c8..79d9bba063 100644 --- a/src/libadmin/bos/afs_bosAdmin.h +++ b/src/libadmin/bos/afs_bosAdmin.h @@ -339,4 +339,9 @@ extern int ADMINAPI bos_Salvage(const void *cellHandle, bos_ForceBlockRead_t forceBlockRead, afs_status_p st); +static_inline struct bozo_key * +kas_to_bozoptr(kas_encryptionKey_p key) +{ + return (struct bozo_key *)key; +} #endif /* OPENAFS_BOS_ADMIN_H */ diff --git a/src/libadmin/kas/afs_kasAdmin.c b/src/libadmin/kas/afs_kasAdmin.c index 72d1be6a72..7c87bebd70 100644 --- a/src/libadmin/kas/afs_kasAdmin.c +++ b/src/libadmin/kas/afs_kasAdmin.c @@ -1803,7 +1803,7 @@ kas_StringToKey(const char *cellName, const char *string, int rc = 0; afs_status_t tst = 0; - ka_StringToKey(string, cellName, (struct ktc_encryptionKey *)key); + ka_StringToKey((char *)string, (char *)cellName, (struct ktc_encryptionKey *)key); rc = 1; if (st != NULL) { diff --git a/src/rxkad/Makefile.in b/src/rxkad/Makefile.in index f3962a8b2a..dc42072571 100644 --- a/src/rxkad/Makefile.in +++ b/src/rxkad/Makefile.in @@ -77,7 +77,7 @@ ticket.o: ticket.c lifetimes.h ${INCLS} $(CC) $(CFLAGS) -c $< ticket5.o: ticket5.c v5gen.c v5der.c v5gen-rewrite.h ${INCLS} - $(CC) -I${srcdir} $(CFLAGS) @CFLAGS_NOERROR@ -c $< + $(CC) -I${srcdir} $(CFLAGS) -c $< crc.o: crc.c ${INCLS} diff --git a/src/rxkad/rxkad_prototypes.h b/src/rxkad/rxkad_prototypes.h index 430b821724..505a65e8fe 100644 --- a/src/rxkad/rxkad_prototypes.h +++ b/src/rxkad/rxkad_prototypes.h @@ -167,6 +167,11 @@ ktc_to_cblock(struct ktc_encryptionKey *key) { return (unsigned char *)key; } +static_inline char * +ktc_to_charptr(struct ktc_encryptionKey *key) { + return (char *)key; +} + static_inline des_cblock * ktc_to_cblockptr(struct ktc_encryptionKey *key) { return (des_cblock *)key; diff --git a/src/uss/uss_kauth.c b/src/uss/uss_kauth.c index 509585f14c..95c7c04eff 100644 --- a/src/uss/uss_kauth.c +++ b/src/uss/uss_kauth.c @@ -166,8 +166,8 @@ InitThisModule(void) char prompt[2 * MAXKTCNAMELEN + 20]; char *reasonString, longPassBuff[1024], shortPassBuff[9]; struct ktc_encryptionKey key; - struct ktc_token token, tok; - struct ktc_principal Name; + struct ktc_token token; + struct ktc_principal Name, tok; /* * Only call this routine once.