summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorEmmanuel Fleury <emmanuel.fleury@u-bordeaux.fr>2019-03-27 13:05:39 +0100
committerEmmanuele Bassi <ebassi@gmail.com>2019-11-25 22:40:11 +0000
commit209eb5981afe3bce1b31f273a46aa20b037b7d3a (patch)
treed16d3eec237e0775f12b31394e099cc62531fcef /gdk-pixbuf
parentae3f3f7d39ffcf2939bc55f746e910bce0f30cf5 (diff)
downloadgdk-pixbuf-209eb5981afe3bce1b31f273a46aa20b037b7d3a.tar.gz
Fix cppcheck 'shifting signed 32-bit value warning'
Changed variable to unsigned and slightly improved algorithm performance (stop when n == 0, no need to keep going until the end). See issue: #96
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/io-bmp.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/gdk-pixbuf/io-bmp.c b/gdk-pixbuf/io-bmp.c
index 13ad6f2bc..4c3ad626a 100644
--- a/gdk-pixbuf/io-bmp.c
+++ b/gdk-pixbuf/io-bmp.c
@@ -626,12 +626,11 @@ static gboolean DecodeColormap (guchar *buff,
static void
find_bits (int n, int *lowest, int *n_set)
{
- int i;
-
+ *lowest = 0;
*n_set = 0;
- for (i = 31; i >= 0; i--)
- if (n & (1 << i)) {
+ for (unsigned int i = 31; n != 0; n <<= 1, i--)
+ if (n & ((unsigned int) 1 << 31)) {
*lowest = i;
(*n_set)++;
}