From: Ben Pfaff Date: Thu, 4 Nov 2010 04:00:52 +0000 (-0700) Subject: sparse-array: Fix accidental assumption that "long" is exactly 32 bits. X-Git-Tag: v0.7.7~146 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ddc66c1a58741ede1a523684e9df919608e6269;p=pspp-builds.git sparse-array: Fix accidental assumption that "long" is exactly 32 bits. Debugged with help from Jeremy Lavergne . --- diff --git a/src/libpspp/sparse-array.c b/src/libpspp/sparse-array.c index 298f2caf..5babbc12 100644 --- a/src/libpspp/sparse-array.c +++ b/src/libpspp/sparse-array.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -534,7 +534,9 @@ scan_in_use_reverse (struct leaf_node *leaf, unsigned int idx) for (;;) { int ofs = idx % LONG_BITS; - unsigned long int in_use = leaf->in_use[idx / LONG_BITS] << (31 - ofs); + unsigned long int in_use; + + in_use = leaf->in_use[idx / LONG_BITS] << (LONG_BITS - 1 - ofs); if (in_use) return idx - count_leading_zeros (in_use); if (idx < LONG_BITS)