diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-11 10:24:13 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-03 11:02:11 -0800 |
commit | 299c9762b1dbe53f3297c54e5526aeae767d1a10 (patch) | |
tree | 13cff7b6c398c528ec8b397d640aa3f43b25db42 /keymap.c | |
parent | e4cba31313b44e40efcc0c260a33c3ec83e4b772 (diff) |
Use unsigned ints when shifting to create bitmasks
symbols.c:1057:28: portability: Shifting signed 32-bit value by 31 bits
is implementation-defined behaviour. See condition at line 1049.
[shiftTooManyBitsSigned]
radio_groups |= (1 << (tmp.uval - 1));
^
symbols.c:1049:41: note: Assuming that condition 'tmp.uval>32' is not redundant
if ((tmp.uval < 1) || (tmp.uval > XkbMaxRadioGroups))
^
symbols.c:1057:28: note: Shift
radio_groups |= (1 << (tmp.uval - 1));
^
symbols.c:1057:28: warning: Either the condition 'tmp.uval>32' is redundant
or there is signed integer overflow for expression '1<<(tmp.uval-1)'.
[integerOverflowCond]
radio_groups |= (1 << (tmp.uval - 1));
^
symbols.c:1049:41: note: Assuming that condition 'tmp.uval>32' is not redundant
if ((tmp.uval < 1) || (tmp.uval > XkbMaxRadioGroups))
^
symbols.c:1057:28: note: Integer overflow
radio_groups |= (1 << (tmp.uval - 1));
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'keymap.c')
-rw-r--r-- | keymap.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -85,7 +85,7 @@ CompileKeymap(XkbFile * file, XkbFileInfo * result, unsigned merge) while ((file) && (ok)) { file->topName = mainName; - if ((have & (1 << file->type)) != 0) + if ((have & (1U << file->type)) != 0) { ERROR("More than one %s section in a %s file\n", XkbConfigText(file->type, XkbMessage), @@ -93,7 +93,7 @@ CompileKeymap(XkbFile * file, XkbFileInfo * result, unsigned merge) ACTION("All sections after the first ignored\n"); ok = False; } - else if ((1 << file->type) & (~legal)) + else if ((1U << file->type) & (~legal)) { ERROR("Cannot define %s in a %s file\n", XkbConfigText(file->type, XkbMessage), @@ -138,7 +138,7 @@ CompileKeymap(XkbFile * file, XkbFileInfo * result, unsigned merge) break; } if (ok) - have |= (1 << file->type); + have |= (1U << file->type); file = (XkbFile *) file->common.next; } /* compile the sections we have in the file one-by-one, or fail. */ |