Use (1u << idx) instead of (1 << idx) where appropriate

It doesn't matter (I think), since the implicit conversion doesn't have
any effect (e.g. sign-extension). But it's better to be aware of the
type.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2014-02-08 15:30:05 +02:00
parent 50b73ec0e7
commit 769b91c580
8 changed files with 34 additions and 34 deletions

View File

@ -631,21 +631,21 @@ xkb_state_led_update_all(struct xkb_state *state)
if (led->which_mods & XKB_STATE_MODS_LOCKED)
mod_mask |= state->components.locked_mods;
if (led->mods.mask & mod_mask)
state->components.leds |= (1 << idx);
state->components.leds |= (1u << idx);
if (led->which_groups & XKB_STATE_LAYOUT_EFFECTIVE)
group_mask |= (1 << state->components.group);
group_mask |= (1u << state->components.group);
if (led->which_groups & XKB_STATE_LAYOUT_DEPRESSED)
group_mask |= (1 << state->components.base_group);
group_mask |= (1u << state->components.base_group);
if (led->which_groups & XKB_STATE_LAYOUT_LATCHED)
group_mask |= (1 << state->components.latched_group);
group_mask |= (1u << state->components.latched_group);
if (led->which_groups & XKB_STATE_LAYOUT_LOCKED)
group_mask |= (1 << state->components.locked_group);
group_mask |= (1u << state->components.locked_group);
if (led->groups & group_mask)
state->components.leds |= (1 << idx);
state->components.leds |= (1u << idx);
if (led->ctrls & state->keymap->enabled_ctrls)
state->components.leds |= (1 << idx);
state->components.leds |= (1u << idx);
}
}
@ -780,7 +780,7 @@ xkb_state_update_mask(struct xkb_state *state,
num_mods = xkb_keymap_num_mods(state->keymap);
for (idx = 0; idx < num_mods; idx++) {
xkb_mod_mask_t mod = (1 << idx);
xkb_mod_mask_t mod = (1u << idx);
if (base_mods & mod)
state->components.base_mods |= mod;
if (latched_mods & mod)
@ -912,7 +912,7 @@ xkb_state_mod_index_is_active(struct xkb_state *state,
if (idx >= xkb_keymap_num_mods(state->keymap))
return -1;
return !!(xkb_state_serialize_mods(state, type) & (1 << idx));
return !!(xkb_state_serialize_mods(state, type) & (1u << idx));
}
/**
@ -963,7 +963,7 @@ xkb_state_mod_indices_are_active(struct xkb_state *state,
ret = -1;
break;
}
wanted |= (1 << idx);
wanted |= (1u << idx);
}
va_end(ap);
@ -1014,7 +1014,7 @@ xkb_state_mod_names_are_active(struct xkb_state *state,
ret = -1;
break;
}
wanted |= (1 << idx);
wanted |= (1u << idx);
}
va_end(ap);
@ -1076,7 +1076,7 @@ xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
darray_item(state->keymap->leds, idx).name == XKB_ATOM_NONE)
return -1;
return !!(state->components.leds & (1 << idx));
return !!(state->components.leds & (1u << idx));
}
/**
@ -1131,7 +1131,7 @@ xkb_state_mod_index_is_consumed(struct xkb_state *state, xkb_keycode_t kc,
if (!key || idx >= xkb_keymap_num_mods(state->keymap))
return -1;
return !!((1 << idx) & key_get_consumed(state, key));
return !!((1u << idx) & key_get_consumed(state, key));
}
/**

View File

@ -280,7 +280,7 @@ ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask)
darray_enumerate(i, mod, keymap->mods) {
int ret;
if (!(mask & (1 << i)))
if (!(mask & (1u << i)))
continue;
ret = snprintf(buf + pos, sizeof(buf) - pos, "%s%s",
@ -307,14 +307,14 @@ LedStateMaskText(struct xkb_context *ctx, enum xkb_state_component mask)
for (unsigned i = 0; mask; i++) {
int ret;
if (!(mask & (1 << i)))
if (!(mask & (1u << i)))
continue;
mask &= ~(1 << i);
mask &= ~(1u << i);
ret = snprintf(buf + pos, sizeof(buf) - pos, "%s%s",
pos == 0 ? "" : "+",
LookupValue(modComponentMaskNames, 1 << i));
LookupValue(modComponentMaskNames, 1u << i));
if (ret <= 0 || pos + ret >= sizeof(buf))
break;
else
@ -339,14 +339,14 @@ ControlMaskText(struct xkb_context *ctx, enum xkb_action_controls mask)
for (unsigned i = 0; mask; i++) {
int ret;
if (!(mask & (1 << i)))
if (!(mask & (1u << i)))
continue;
mask &= ~(1 << i);
mask &= ~(1u << i);
ret = snprintf(buf + pos, sizeof(buf) - pos, "%s%s",
pos == 0 ? "" : "+",
LookupValue(ctrlMaskNames, 1 << i));
LookupValue(ctrlMaskNames, 1u << i));
if (ret <= 0 || pos + ret >= sizeof(buf))
break;
else

View File

@ -684,7 +684,7 @@ get_indicators(struct xkb_keymap *keymap, xcb_connection_t *conn,
darray_resize0(keymap->leds, msb_pos(reply->which));
for (int i = 0; i < NUM_INDICATORS; i++) {
if (reply->which & (1 << i)) {
if (reply->which & (1u << i)) {
xcb_xkb_indicator_map_t *wire = iter.data;
struct xkb_led *led = &darray_item(keymap->leds, i);
@ -886,7 +886,7 @@ get_indicator_names(struct xkb_keymap *keymap, xcb_connection_t *conn,
FAIL_UNLESS(msb_pos(reply->indicators) <= (int) darray_size(keymap->leds));
for (int i = 0; i < NUM_INDICATORS; i++) {
if (reply->indicators & (1 << i)) {
if (reply->indicators & (1u << i)) {
xcb_atom_t wire = *iter;
struct xkb_led *led = &darray_item(keymap->leds, i);

View File

@ -116,7 +116,7 @@ LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
if (ndx == XKB_MOD_INVALID)
return false;
*val_rtrn = (1 << ndx);
*val_rtrn = (1u << ndx);
return true;
}

View File

@ -635,7 +635,7 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf)
continue;
darray_enumerate(i, mod, keymap->mods)
if (key->modmap & (1 << i))
if (key->modmap & (1u << i))
write_buf(buf, "\tmodifier_map %s { %s };\n",
xkb_atom_text(keymap->ctx, mod->name),
KeyNameText(keymap->ctx, key->name));

View File

@ -39,7 +39,7 @@ ComputeEffectiveMask(struct xkb_keymap *keymap, struct xkb_mods *mods)
mods->mask = mods->mods & MOD_REAL_MASK_ALL;
darray_enumerate(i, mod, keymap->mods)
if (mods->mods & (1 << i))
if (mods->mods & (1u << i))
mods->mask |= mod->mapping;
}
@ -158,7 +158,7 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key)
if ((group == 0 && level == 0) || !interp->level_one_only)
if (interp->virtual_mod != XKB_MOD_INVALID)
vmodmap |= (1 << interp->virtual_mod);
vmodmap |= (1u << interp->virtual_mod);
if (interp->action.type != ACTION_TYPE_NONE)
key->groups[group].levels[level].action = interp->action;
@ -194,7 +194,7 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
/* Update keymap->mods, the virtual -> real mod mapping. */
xkb_foreach_key(key, keymap)
darray_enumerate(i, mod, keymap->mods)
if (key->vmodmap & (1 << i))
if (key->vmodmap & (1u << i))
mod->mapping |= key->modmap;
/* Now update the level masks for all the types to reflect the vmods. */

View File

@ -482,7 +482,7 @@ matcher_mapping_set_mlvo(struct matcher *m, struct sval ident)
return;
}
if (m->mapping.defined_mlvo_mask & (1 << mlvo)) {
if (m->mapping.defined_mlvo_mask & (1u << mlvo)) {
matcher_error(m,
"invalid mapping: %.*s appears twice on the same line; "
"ignoring rule set",
@ -522,7 +522,7 @@ matcher_mapping_set_mlvo(struct matcher *m, struct sval ident)
}
m->mapping.mlvo_at_pos[m->mapping.num_mlvo] = mlvo;
m->mapping.defined_mlvo_mask |= 1 << mlvo;
m->mapping.defined_mlvo_mask |= 1u << mlvo;
m->mapping.num_mlvo++;
}
@ -549,7 +549,7 @@ matcher_mapping_set_kccgst(struct matcher *m, struct sval ident)
return;
}
if (m->mapping.defined_kccgst_mask & (1 << kccgst)) {
if (m->mapping.defined_kccgst_mask & (1u << kccgst)) {
matcher_error(m,
"invalid mapping: %.*s appears twice on the same line; "
"ignoring rule set",
@ -559,7 +559,7 @@ matcher_mapping_set_kccgst(struct matcher *m, struct sval ident)
}
m->mapping.kccgst_at_pos[m->mapping.num_kccgst] = kccgst;
m->mapping.defined_kccgst_mask |= 1 << kccgst;
m->mapping.defined_kccgst_mask |= 1u << kccgst;
m->mapping.num_kccgst++;
}
@ -585,7 +585,7 @@ matcher_mapping_verify(struct matcher *m)
* See the "Notes" section in the overview above.
*/
if (m->mapping.defined_mlvo_mask & (1 << MLVO_LAYOUT)) {
if (m->mapping.defined_mlvo_mask & (1u << MLVO_LAYOUT)) {
if (m->mapping.layout_idx == XKB_LAYOUT_INVALID) {
if (darray_size(m->rmlvo.layouts) > 1)
goto skip;
@ -597,7 +597,7 @@ matcher_mapping_verify(struct matcher *m)
}
}
if (m->mapping.defined_mlvo_mask & (1 << MLVO_VARIANT)) {
if (m->mapping.defined_mlvo_mask & (1u << MLVO_VARIANT)) {
if (m->mapping.variant_idx == XKB_LAYOUT_INVALID) {
if (darray_size(m->rmlvo.variants) > 1)
goto skip;

View File

@ -1511,7 +1511,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
}
}
key->modmap |= (1 << entry->modifier);
key->modmap |= (1u << entry->modifier);
return true;
}