summaryrefslogtreecommitdiff
path: root/symbols.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-11 10:24:13 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-01-03 11:02:11 -0800
commit299c9762b1dbe53f3297c54e5526aeae767d1a10 (patch)
tree13cff7b6c398c528ec8b397d640aa3f43b25db42 /symbols.c
parente4cba31313b44e40efcc0c260a33c3ec83e4b772 (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 'symbols.c')
-rw-r--r--symbols.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/symbols.c b/symbols.c
index d5c2af4..ab11756 100644
--- a/symbols.c
+++ b/symbols.c
@@ -451,10 +451,10 @@ MergeKeyGroups(SymbolsInfo * info,
from->syms[group] = NULL;
into->acts[group] = resultActs;
from->acts[group] = NULL;
- into->symsDefined |= (1 << group);
- from->symsDefined &= ~(1 << group);
- into->actsDefined |= (1 << group);
- from->actsDefined &= ~(1 << group);
+ into->symsDefined |= (1U << group);
+ from->symsDefined &= ~(1U << group);
+ into->actsDefined |= (1U << group);
+ from->actsDefined &= ~(1U << group);
return True;
}
@@ -490,11 +490,11 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
into->numLevels[i] = from->numLevels[i];
into->syms[i] = from->syms[i];
into->acts[i] = from->acts[i];
- into->symsDefined |= (1 << i);
+ into->symsDefined |= (1U << i);
from->syms[i] = NULL;
from->acts[i] = NULL;
from->numLevels[i] = 0;
- from->symsDefined &= ~(1 << i);
+ from->symsDefined &= ~(1U << i);
if (into->syms[i])
into->defs.defined |= _Key_Syms;
if (into->acts[i])
@@ -876,7 +876,7 @@ GetGroupIndex(KeyInfo * key,
for (int i = 0; i < XkbNumKbdGroups; i++)
{
- if ((defined & (1 << i)) == 0)
+ if ((defined & (1U << i)) == 0)
{
*ndx_rtrn = i;
return True;
@@ -918,7 +918,7 @@ AddSymbolsToKey(KeyInfo * key,
return False;
if (value == NULL)
{
- key->symsDefined |= (1 << ndx);
+ key->symsDefined |= (1U << ndx);
return True;
}
if (value->op != ExprKeysymList)
@@ -944,7 +944,7 @@ AddSymbolsToKey(KeyInfo * key,
ACTION("Symbols lost\n");
return False;
}
- key->symsDefined |= (1 << ndx);
+ key->symsDefined |= (1U << ndx);
for (int i = 0; i < nSyms; i++) {
if (!LookupKeysym(value->value.list.syms[i], &key->syms[ndx][i])) {
if (warningLevel > 0)
@@ -978,7 +978,7 @@ AddActionsToKey(KeyInfo * key,
if (value == NULL)
{
- key->actsDefined |= (1 << ndx);
+ key->actsDefined |= (1U << ndx);
return True;
}
if (value->op != ExprActionList)
@@ -1011,7 +1011,7 @@ AddActionsToKey(KeyInfo * key,
ACTION("Actions lost\n");
return False;
}
- key->actsDefined |= (1 << ndx);
+ key->actsDefined |= (1U << ndx);
toAct = (XkbAnyAction *) key->acts[ndx];
act = value->value.child;
@@ -1054,7 +1054,7 @@ SetAllowNone(KeyInfo * key, ExprDef * arrayNdx, ExprDef * value)
tmp.uval);
return False;
}
- radio_groups |= (1 << (tmp.uval - 1));
+ radio_groups |= (1U << (tmp.uval - 1));
}
if (!ExprResolveBoolean(value, &tmp, NULL, NULL))
{
@@ -1140,7 +1140,7 @@ SetSymbolsField(KeyInfo * key,
else
{
key->types[ndx.uval - 1] = XkbInternAtom(NULL, tmp.str, False);
- key->typesDefined |= (1 << (ndx.uval - 1));
+ key->typesDefined |= (1U << (ndx.uval - 1));
}
}
else if (uStrCaseCmp(field, "symbols") == 0)
@@ -1206,7 +1206,7 @@ SetSymbolsField(KeyInfo * key,
key->behavior.type =
XkbKB_RadioGroup | (permanent ? XkbKB_Permanent : 0);
key->behavior.data = tmp.uval - 1;
- if (key->allowNone & (1 << (tmp.uval - 1)))
+ if (key->allowNone & (1U << (tmp.uval - 1)))
key->behavior.data |= XkbKB_RGAllowNone;
key->defs.defined |= _Key_Behavior;
}
@@ -1532,7 +1532,7 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
key->types[i] = (Atom) 0;
}
}
- key->typesDefined = key->symsDefined = key->actsDefined = 1 << group;
+ key->typesDefined = key->symsDefined = key->actsDefined = 1U << group;
key->numLevels[group] = key->numLevels[0];
key->numLevels[0] = 0;
@@ -1831,7 +1831,7 @@ PrepareKeyDef(KeyInfo * key)
/* get highest group number */
for (i = XkbNumKbdGroups - 1; i >= 0; i--)
{
- if (defined & (1 << i))
+ if (defined & (1U << i))
break;
}
lastGroup = i;
@@ -1846,7 +1846,7 @@ PrepareKeyDef(KeyInfo * key)
{
int width;
- if (defined & (1 << i))
+ if (defined & (1U << i))
continue;
width = key->numLevels[0];
if (key->typesDefined & 1)
@@ -1855,7 +1855,7 @@ PrepareKeyDef(KeyInfo * key)
{
key->types[i] = key->types[0];
}
- key->typesDefined |= 1 << i;
+ key->typesDefined |= 1U << i;
}
if ((key->actsDefined & 1) && key->acts[0])
{
@@ -1863,7 +1863,7 @@ PrepareKeyDef(KeyInfo * key)
if (key->acts[i] == NULL)
continue;
memcpy(key->acts[i], key->acts[0], width * sizeof(XkbAction));
- key->actsDefined |= 1 << i;
+ key->actsDefined |= 1U << i;
}
if ((key->symsDefined & 1) && key->syms[0])
{
@@ -1871,7 +1871,7 @@ PrepareKeyDef(KeyInfo * key)
if (key->syms[i] == NULL)
continue;
memcpy(key->syms[i], key->syms[0], width * sizeof(KeySym));
- key->symsDefined |= 1 << i;
+ key->symsDefined |= 1U << i;
}
if (defined & 1)
{
@@ -1962,8 +1962,8 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
for (i = width = nGroups = 0; i < XkbNumKbdGroups; i++)
{
if (((i + 1) > nGroups)
- && (((key->symsDefined | key->actsDefined) & (1 << i))
- || (key->typesDefined) & (1 << i)))
+ && (((key->symsDefined | key->actsDefined) & (1U << i))
+ || (key->typesDefined) & (1U << i)))
nGroups = i + 1;
if (key->acts[i])
haveActions = True;
@@ -1993,7 +1993,7 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
if (FindNamedType(xkb, key->types[i], &types[i]))
{
if (!autoType || key->numLevels[i] > 2)
- xkb->server->explicit[kc] |= (1 << i);
+ xkb->server->explicit[kc] |= (1U << i);
}
else
{
@@ -2128,9 +2128,9 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
if (key->repeat != RepeatUndefined)
{
if (key->repeat == RepeatYes)
- xkb->ctrls->per_key_repeat[kc / 8] |= (1 << (kc % 8));
+ xkb->ctrls->per_key_repeat[kc / 8] |= (1U << (kc % 8));
else
- xkb->ctrls->per_key_repeat[kc / 8] &= ~(1 << (kc % 8));
+ xkb->ctrls->per_key_repeat[kc / 8] &= ~(1U << (kc % 8));
xkb->server->explicit[kc] |= XkbExplicitAutoRepeatMask;
}
@@ -2174,7 +2174,7 @@ CopyModMapDef(XkbFileInfo * result, ModMapEntry * entry)
}
return False;
}
- xkb->map->modmap[kc] |= (1 << entry->modifier);
+ xkb->map->modmap[kc] |= (1U << entry->modifier);
return True;
}