From 281b5385855e98c9aa989bfba91451c56a1b73f1 Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Fri, 20 Jul 2012 18:11:38 -0400 Subject: [PATCH] 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 --- src/afs/UKERNEL/afs_usrops.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) 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); -- 2.39.5