From: Andrew Deason Date: Wed, 7 Oct 2009 21:42:42 +0000 (-0500) Subject: Remove warnings related to type-punning X-Git-Tag: openafs-devel-1_5_66~98 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=549002c906795f978eebf81c706995116a04a8ff Remove warnings related to type-punning cmd/cmd.c: - Just make dummy be a struct cmd_item instead of casting rxdebug/rxdebug.c: - Access the stats packet through a union instead of casting and dereferencing util/uuid.c: - Access the seed through a union and an array instead of that incrementing-pointer approach Reviewed-on: http://gerrit.openafs.org/599 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/cmd/cmd.c b/src/cmd/cmd.c index 66b4ef4..3b5302e 100644 --- a/src/cmd/cmd.c +++ b/src/cmd/cmd.c @@ -25,7 +25,7 @@ struct cmd_token { char *key; }; -static int dummy; /* non-null ptr used for flag existence */ +static struct cmd_item dummy; /* non-null ptr used for flag existence */ static struct cmd_syndesc *allSyntax = 0; static int noOpcodes = 0; static int (*beforeProc) (struct cmd_syndesc * ts, void *beforeRock) = NULL; @@ -800,7 +800,7 @@ cmd_Dispatch(int argc, char **argv) return (CMD_INTERNALERROR); } if (ts->parms[j].type == CMD_FLAG) { - ts->parms[j].items = (struct cmd_item *)&dummy; + ts->parms[j].items = &dummy; } else { positional = 0; curType = j; diff --git a/src/rxdebug/rxdebug.c b/src/rxdebug/rxdebug.c index a231cf1..273a49a 100644 --- a/src/rxdebug/rxdebug.c +++ b/src/rxdebug/rxdebug.c @@ -278,19 +278,21 @@ MainCommand(struct cmd_syndesc *as, void *arock) fprintf(stderr, "WARNING: Server doesn't support retrieval of Rx statistics\n"); } else { - struct rx_statistics rxstats; + union { + struct rx_statistics rxstats; + struct rx_debugIn debug; + } packet; /* should gracefully handle the case where rx_stats grows */ code = - rx_GetServerStats(s, host, port, &rxstats, + rx_GetServerStats(s, host, port, &packet.rxstats, &supportedStatValues); if (code < 0) { printf("rxstats call failed with code %d\n", code); exit(1); } - if (code != sizeof(rxstats)) { - if ((((struct rx_debugIn *)(&rxstats))->type == - RX_DEBUGI_BADTYPE)) + if (code != sizeof(packet.rxstats)) { + if (packet.debug.type == RX_DEBUGI_BADTYPE) goto noRxStats; printf ("WARNING: returned Rx statistics of unexpected size (got %d)\n", @@ -298,7 +300,7 @@ MainCommand(struct cmd_syndesc *as, void *arock) /* handle other versions?... */ } - rx_PrintTheseStats(stdout, &rxstats, sizeof(rxstats), + rx_PrintTheseStats(stdout, &packet.rxstats, sizeof(packet.rxstats), tstats.nFreePackets, tstats.version); } } diff --git a/src/util/uuid.c b/src/util/uuid.c index 4fc3ad0..7439311 100644 --- a/src/util/uuid.c +++ b/src/util/uuid.c @@ -247,8 +247,11 @@ afs_uuid_create(afsUUID * uuid) afs_int32 got_no_time = 0, code; if (!uuid_init_done) { - uuid_time_t t; - u_short *seedp, seed = 0; + union { + uuid_time_t t; + u_short seed[4]; + } uuid_time; + u_short seed = 0; rand_m = 971;; rand_ia = 11113; rand_ib = 104322; @@ -264,12 +267,11 @@ afs_uuid_create(afsUUID * uuid) * independent. Then for good measure to ensure a unique seed when there * are multiple processes creating UUID's on a system, we add in the PID. */ - uuid__get_os_time(&t); - seedp = (u_short *) (&t); - seed ^= *seedp++; - seed ^= *seedp++; - seed ^= *seedp++; - seed ^= *seedp++; + uuid__get_os_time(&uuid_time.t); + seed ^= uuid_time.seed[0]; + seed ^= uuid_time.seed[1]; + seed ^= uuid_time.seed[2]; + seed ^= uuid_time.seed[3]; #if defined(KERNEL) && defined(AFS_XBSD_ENV) rand_irand += seed + (afs_uint32) curproc->p_pid; #else