From 304fac42b8cd4a71d0df063cafe88b2888e4d175 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. Change-Id: Iab285d3a04dac698797ab0df2337aee75e3876b2 Reviewed-on: http://gerrit.openafs.org/9137 Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Derrick Brashear Tested-by: BuildBot --- 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 67ccb6b..a314ab7 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 384f6de..39a3aa1 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -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 */ diff --git a/src/vol/volume_inline.h b/src/vol/volume_inline.h index 1fc8855..7b3b831 100644 --- a/src/vol/volume_inline.h +++ b/src/vol/volume_inline.h @@ -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; } -- 1.9.4