vol: Don't assume enum is an int
authorSimon Wilkinson <sxw@your-file-system.com>
Fri, 15 Feb 2013 17:22:02 +0000 (17:22 +0000)
committerDerrick Brashear <shadow@your-file-system.com>
Wed, 20 Feb 2013 18:23:10 +0000 (10:23 -0800)
The type that an enum is promoted to for arithmetic is compiler
dependent. We can't assume that it's an int, or a short.

Explicitly cast the volume state enum where clang gets upset.

Change-Id: Iab285d3a04dac698797ab0df2337aee75e3876b2
Reviewed-on: http://gerrit.openafs.org/9137
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/vol/vnode_inline.h
src/vol/volume.c
src/vol/volume_inline.h

index 67ccb6b..a314ab7 100644 (file)
@@ -236,7 +236,7 @@ VnIsErrorState(VnState state)
 static_inline int
 VnIsValidState(VnState state)
 {
-    if ((state >= 0) &&
+    if (((int) state >= 0) &&
        (state < VN_STATE_COUNT)) {
        return 1;
     }
index 384f6de..39a3aa1 100644 (file)
@@ -1848,9 +1848,9 @@ VShutdownVolume_r(Volume * vp)
     VCreateReservation_r(vp);
 
     if (LogLevel >= 5) {
-       Log("VShutdownVolume_r:  vid=%" AFS_VOLID_FMT ", device=%d, state=%hu\n",
+       Log("VShutdownVolume_r:  vid=%" AFS_VOLID_FMT ", device=%d, state=%u\n",
            afs_printable_VolumeId_lu(vp->hashid), vp->partition->device,
-           V_attachState(vp));
+           (unsigned int) V_attachState(vp));
     }
 
     /* wait for other blocking ops to finish */
index 1fc8855..7b3b831 100644 (file)
@@ -424,7 +424,7 @@ VIsOfflineState(VolState state)
 static_inline int
 VIsValidState(VolState state)
 {
-    if ((state >= 0) &&
+    if (((int) state >= 0) &&
        (state < VOL_STATE_COUNT)) {
        return 1;
     }