diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-15 18:17:33 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-15 18:18:08 +0100 |
commit | f6c29f62283b05ca12bc032870b5e69bd50d82ba (patch) | |
tree | 6c7f2633466d77838503824d6db577f9ce3a0bb4 /mach-defpager | |
parent | 56d065041793509a6f60671f6ae3400698bd5639 (diff) | |
download | hurd-f6c29f62283b05ca12bc032870b5e69bd50d82ba.tar.gz hurd-f6c29f62283b05ca12bc032870b5e69bd50d82ba.tar.bz2 hurd-f6c29f62283b05ca12bc032870b5e69bd50d82ba.zip |
Fix accessing bit 31
Shifting (signed) 1 to left 31 positions is undefined behavior. So make
this an unsigned so it becomes defined behavior.
Diffstat (limited to 'mach-defpager')
-rw-r--r-- | mach-defpager/default_pager.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/mach-defpager/default_pager.c b/mach-defpager/default_pager.c index 78bcb279..02d1f1a9 100644 --- a/mach-defpager/default_pager.c +++ b/mach-defpager/default_pager.c @@ -268,13 +268,13 @@ new_partition (const char *name, struct file_direct *fdp, continue; /* There are some zero bits in this word. */ for (j = 0; j < 32; ++j) - if ((bm & (1 << j)) == 0) + if ((bm & (1U << j)) == 0) { unsigned int p = i*32 + j; if (p >= part->total_size) break; ++bad; - part->bitmap[p / NB_BM] |= 1 << (p % NB_BM); + part->bitmap[p / NB_BM] |= 1U << (p % NB_BM); } } part->free -= bad; @@ -371,7 +371,7 @@ new_partition (const char *name, struct file_direct *fdp, for (i = 0; i < hdr->nr_badpages; ++i) { const u_int32_t bad = hdr->badpages[i]; - part->bitmap[bad / NB_BM] |= 1 << (bad % NB_BM); + part->bitmap[bad / NB_BM] |= 1U << (bad % NB_BM); part->free--; } printf ("%uk swap-space", @@ -556,12 +556,12 @@ ddprintf ("pager_alloc_page(%d,%d)\n",pindex,lock_it); bm_entry_t b = *bm; for (bit = 0; bit < NB_BM; bit++) - if ((b & (1<<bit)) == 0) + if ((b & (1U<<bit)) == 0) break; if (bit == NB_BM) panic(here,my_name); - *bm = b | (1<<bit); + *bm = b | (1U<<bit); part->free--; } @@ -598,7 +598,7 @@ ddprintf ("pager_dealloc_page(%d,%lx,%d)\n",pindex,page,lock_it); if (lock_it) pthread_mutex_lock(&part->p_lock); - part->bitmap[bm_e] &= ~(1<<bit); + part->bitmap[bm_e] &= ~(1U<<bit); part->free++; if (lock_it) |