From 46f6f368a6da15b62beec07bcd3f3f42ca272d94 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Fri, 15 Feb 2013 17:22:02 +0000 Subject: [PATCH] vol: Don't assume enum is an int 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. Reviewed-on: http://gerrit.openafs.org/9137 Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Derrick Brashear Tested-by: BuildBot (cherry picked from commit 304fac42b8cd4a71d0df063cafe88b2888e4d175) Change-Id: I8c5b3493549ec88727728a7f28e3430660c673b2 Reviewed-on: http://gerrit.openafs.org/10748 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/vol/vnode_inline.h | 2 +- src/vol/volume.c | 4 ++-- src/vol/volume_inline.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vol/vnode_inline.h b/src/vol/vnode_inline.h index f31c5ca29..a076a06c8 100644 --- a/src/vol/vnode_inline.h +++ b/src/vol/vnode_inline.h @@ -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; } diff --git a/src/vol/volume.c b/src/vol/volume.c index f88c6fbbd..7af7c65bc 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -1841,8 +1841,8 @@ VShutdownVolume_r(Volume * vp) VCreateReservation_r(vp); if (LogLevel >= 5) { - Log("VShutdownVolume_r: vid=%u, device=%d, state=%hu\n", - vp->hashid, vp->partition->device, V_attachState(vp)); + Log("VShutdownVolume_r: vid=%u, device=%d, state=%u\n", + vp->hashid, vp->partition->device, (unsigned int)V_attachState(vp)); } /* wait for other blocking ops to finish */ diff --git a/src/vol/volume_inline.h b/src/vol/volume_inline.h index 342288217..2ca112c32 100644 --- a/src/vol/volume_inline.h +++ b/src/vol/volume_inline.h @@ -418,7 +418,7 @@ VIsOfflineState(VolState state) static_inline int VIsValidState(VolState state) { - if ((state >= 0) && + if (((int) state >= 0) && (state < VOL_STATE_COUNT)) { return 1; } -- 2.39.5