From: Garrett Wollman Date: Fri, 20 Jul 2012 22:11:38 +0000 (-0400) Subject: uafs: avoid unnecessary type-punning X-Git-Tag: upstream/1.8.0_pre1^2~2202 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=281b5385855e98c9aa989bfba91451c56a1b73f1;p=packages%2Fo%2Fopenafs.git uafs: avoid unnecessary type-punning There's no need to declare a separate buffer and initialize a structure inside it when we can just instantiate the structure directly. Change-Id: Idbcad31343ce7f074015f5921a4997d3f6c9799a Reviewed-on: http://gerrit.openafs.org/7798 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear --- diff --git a/src/afs/UKERNEL/afs_usrops.c b/src/afs/UKERNEL/afs_usrops.c index 2b37ce5bd..b44e54bde 100644 --- a/src/afs/UKERNEL/afs_usrops.c +++ b/src/afs/UKERNEL/afs_usrops.c @@ -3735,13 +3735,12 @@ uafs_getvolquota(char *path, afs_int32 * BlocksInUse, afs_int32 * MaxQuota) { int rc; struct afs_ioctl iob; - VolumeStatus *status; - char buf[1024]; + VolumeStatus status; iob.in = 0; iob.in_size = 0; - iob.out = buf; - iob.out_size = 1024; + iob.out = (char *)&status; + iob.out_size = sizeof status; rc = call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(4), (long)&iob, 0, 0); @@ -3751,9 +3750,8 @@ uafs_getvolquota(char *path, afs_int32 * BlocksInUse, afs_int32 * MaxQuota) return -1; } - status = (VolumeStatus *) buf; - *BlocksInUse = status->BlocksInUse; - *MaxQuota = status->MaxQuota; + *BlocksInUse = status.BlocksInUse; + *MaxQuota = status.MaxQuota; return 0; } @@ -3766,18 +3764,15 @@ uafs_setvolquota(char *path, afs_int32 MaxQuota) { int rc; struct afs_ioctl iob; - VolumeStatus *status; - char buf[1024]; + VolumeStatus status = { 0 }; - iob.in = buf; - iob.in_size = 1024; + iob.in = (char *)&status; + iob.in_size = sizeof status; iob.out = 0; iob.out_size = 0; - memset(buf, 0, sizeof(VolumeStatus)); - status = (VolumeStatus *) buf; - status->MaxQuota = MaxQuota; - status->MinQuota = -1; + status.MaxQuota = MaxQuota; + status.MinQuota = -1; rc = call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(5), (long)&iob, 0, 0);