From: Ivan Maidanski Date: Mon, 6 Feb 2012 04:44:33 +0000 (+0400) Subject: Suppress compiler warning in atomic_ops_malloc X-Git-Tag: libatomic_ops-7_3alpha2~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=819e4e113eeec286dbe088979f723e022db2b6a3;p=libatomic_ops Suppress compiler warning in atomic_ops_malloc * src/atomic_ops_malloc.c (msb): Change shift-by-32 expression to work around a warning issued by clang compiler. --- diff --git a/src/atomic_ops_malloc.c b/src/atomic_ops_malloc.c index d4a0f21..bb1e949 100644 --- a/src/atomic_ops_malloc.c +++ b/src/atomic_ops_malloc.c @@ -235,11 +235,9 @@ int msb(size_t s) int result = 0; int v; if ((s & 0xff) != s) { - /* The following shift often generates warnings on 32-bit arch's */ - /* That's OK, because it will never be executed there. */ - /* Doing the shift only in a conditional expression suppresses the */ - /* warning with the modern compilers. */ - if (sizeof(size_t) > 4 && (v = s >> 32) != 0) + /* The following is a tricky code ought to be equivalent to */ + /* "(v = s >> 32) != 0" but suppresses warnings on 32-bit arch's. */ + if (sizeof(size_t) > 4 && (v = s >> (sizeof(size_t) > 4 ? 32 : 0)) != 0) { s = v; result += 32;