Fix some dodgy shifts

While I guess ubsan is right that shifting a 1 bit into the sign of an
int can cause problems, but that's assuming the int is numeric. And it
doesn't help that unsigned char promotes to int instead of unsigned int.
This commit is contained in:
Bill Currie 2024-09-24 10:54:17 +09:00
parent e3d403cada
commit 867e49980f
3 changed files with 3 additions and 3 deletions

View file

@ -732,7 +732,7 @@ draw_sigils (view_t view, void *data)
{ {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
view_t sigil = View_GetChild (view, i); view_t sigil = View_GetChild (view, i);
if (sbar_stats[STAT_ITEMS] & (1 << (28 + i))) { if (sbar_stats[STAT_ITEMS] & (1u << (28 + i))) {
sbar_setcomponent (sigil, canvas_pic, &sb_sigil[i]); sbar_setcomponent (sigil, canvas_pic, &sb_sigil[i]);
} else { } else {
sbar_remcomponent (sigil, canvas_pic); sbar_remcomponent (sigil, canvas_pic);

View file

@ -156,7 +156,7 @@ copy64 (uint32_t * M, const unsigned char *in)
int i; int i;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
M[i] = (in[i * 4 + 3] << 24) | (in[i * 4 + 2] << 16) | M[i] = ((uint32_t) in[i * 4 + 3] << 24) | (in[i * 4 + 2] << 16) |
(in[i * 4 + 1] << 8) | (in[i * 4 + 0] << 0); (in[i * 4 + 1] << 8) | (in[i * 4 + 0] << 0);
} }

View file

@ -593,7 +593,7 @@ CL_ParseClientdata (void)
if (cl.stats[STAT_ITEMS] != i) { // set flash times if (cl.stats[STAT_ITEMS] != i) { // set flash times
for (j = 0; j < 32; j++) for (j = 0; j < 32; j++)
if ((i & (1 << j)) && !(cl.stats[STAT_ITEMS] & (1 << j))) if ((i & (1u << j)) && !(cl.stats[STAT_ITEMS] & (1u << j)))
cl.item_gettime[j] = cl.time; cl.item_gettime[j] = cl.time;
cl.stats[STAT_ITEMS] = i; cl.stats[STAT_ITEMS] = i;
#define IT_POWER (IT_QUAD | IT_SUIT | IT_INVULNERABILITY | IT_INVISIBILITY) #define IT_POWER (IT_QUAD | IT_SUIT | IT_INVULNERABILITY | IT_INVISIBILITY)