Skip to content

Commit

Permalink
thread: Use explicit wide type when shifting > 32 bits
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Graf authored and blp committed Aug 29, 2014
1 parent 6565262 commit b08b678
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ovs-thread.c
Expand Up @@ -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)) {
Expand Down

0 comments on commit b08b678

Please sign in to comment.