[PATCH] server: use longer int in bitshift operation (Coverity)

Marcus Meissner marcus at jet.franken.de
Thu Apr 17 00:38:18 CDT 2014


1195662 Bad bit shift operation

1<<x only does "integers", so 1<<32 and higher will result
in 0. cast to affinity_t instead of using ULL suffix for more
portability.
---
 server/thread.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/thread.c b/server/thread.c
index 896ce0f..3e06ba3 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -450,10 +450,10 @@ affinity_t get_thread_affinity( struct thread *thread )
 
         if (!sched_getaffinity( thread->unix_tid, sizeof(set), &set ))
             for (i = 0; i < 8 * sizeof(mask); i++)
-                if (CPU_ISSET( i, &set )) mask |= 1 << i;
+                if (CPU_ISSET( i, &set )) mask |= ((affinity_t)1) << i;
     }
 #endif
-    if (!mask) mask = ~0;
+    if (!mask) mask = ~((affinity_t)0);
     return mask;
 }
 
-- 
1.8.4.5




More information about the wine-patches mailing list