viced: Avoid clang errors with modeBits
authorSimon Wilkinson <sxw@your-file-system.com>
Fri, 15 Feb 2013 17:12:45 +0000 (17:12 +0000)
committerDerrick Brashear <shadow@your-file-system.com>
Wed, 20 Feb 2013 18:23:04 +0000 (10:23 -0800)
The modeBits element of the VnodeDiskObject structure is defined as
a 12 bit wide bitfield. This causes clang some problems when doing
integer arithmetic, as it appears to the compiler that the field is
being overflowed. For example...

    targetptr->disk.modeBits &= ~04000;

Produces the error:
    implicit truncation from 'int' to bitfield changes value
from -2049 to 2047

Marc Dionne suggested changing this to
    targetptr->disk.modeBits = targetptr->disk.modeBits & ~04000;

in order to suppress the clang error.

Change-Id: Iadb53a3db911f5771d3ab2437ccd43abce2a8ecb
Reviewed-on: http://gerrit.openafs.org/9136
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/viced/afsfileprocs.c

index 9190133..b400c99 100644 (file)
@@ -1701,9 +1701,11 @@ Update_TargetVnodeStatus(Vnode * targetptr, afs_uint32 Caller,
     if (Caller & TVS_SDATA) {
        targetptr->disk.dataVersion++;
        if (!remote && VanillaUser(client)) {
-           targetptr->disk.modeBits &= ~04000; /* turn off suid for file. */
+           /* turn off suid */
+           targetptr->disk.modeBits = targetptr->disk.modeBits & ~04000;
 #ifdef CREATE_SGUID_ADMIN_ONLY
-           targetptr->disk.modeBits &= ~02000; /* turn off sgid for file. */
+           /* turn off sgid */
+           targetptr->disk.modeBits = targetptr->disk.modeBits & ~02000;
 #endif
        }
     }
@@ -1719,9 +1721,11 @@ Update_TargetVnodeStatus(Vnode * targetptr, afs_uint32 Caller,
     if (InStatus->Mask & AFS_SETOWNER) {
        /* admin is allowed to do chmod, chown as well as chown, chmod. */
        if (!remote && VanillaUser(client)) {
-           targetptr->disk.modeBits &= ~04000; /* turn off suid for file. */
+           /* turn off suid */
+           targetptr->disk.modeBits = targetptr->disk.modeBits & ~04000;
 #ifdef CREATE_SGUID_ADMIN_ONLY
-           targetptr->disk.modeBits &= ~02000; /* turn off sgid for file. */
+           /* turn off sgid */
+           targetptr->disk.modeBits = targetptr->disk.modeBits & ~02000;
 #endif
        }
        targetptr->disk.owner = InStatus->Owner;