thread: Use explicit wide type when shifting > 32 bits
authorThomas Graf <tgraf@noironetworks.com>
Fri, 29 Aug 2014 10:21:49 +0000 (12:21 +0200)
committerBen Pfaff <blp@nicira.com>
Fri, 29 Aug 2014 17:48:42 +0000 (10:48 -0700)
Without the explicit wide type, the shift operation may be performed
on a int which will result in implementation defined behaviour on a
system with more than 32 CPUs.

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ovs-thread.c

index 176f434..529756f 100644 (file)
@@ -510,11 +510,11 @@ parse_cpuinfo(long int *n_cores)
                 break;
             }
 
-            if (cpu & (1 << id)) {
+            if (cpu & (1ULL << id)) {
                 /* We've already counted this package's cores. */
                 continue;
             }
-            cpu |= 1 << id;
+            cpu |= 1ULL << id;
 
             /* Find the number of cores for this package. */
             while (fgets(line, sizeof line, stream)) {