From: Ran Benita Date: Sat, 8 Feb 2014 13:30:05 +0000 (+0200) Subject: Use (1u << idx) instead of (1 << idx) where appropriate X-Git-Tag: xkbcommon-0.4.1~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=769b91c580832eea279770d8a14f8aa23bf16f34;p=platform%2Fupstream%2Flibxkbcommon.git 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 --- diff --git a/src/state.c b/src/state.c index 3298592..bf90688 100644 --- a/src/state.c +++ b/src/state.c @@ -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)); } /** diff --git a/src/text.c b/src/text.c index 59d6c77..f3a09e8 100644 --- a/src/text.c +++ b/src/text.c @@ -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 diff --git a/src/x11/keymap.c b/src/x11/keymap.c index 9d680b1..8581a79 100644 --- a/src/x11/keymap.c +++ b/src/x11/keymap.c @@ -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); diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index ba71208..7b6ecc9 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -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; } diff --git a/src/xkbcomp/keymap-dump.c b/src/xkbcomp/keymap-dump.c index 0f5b958..fe41675 100644 --- a/src/xkbcomp/keymap-dump.c +++ b/src/xkbcomp/keymap-dump.c @@ -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)); diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c index aee631f..8a70577 100644 --- a/src/xkbcomp/keymap.c +++ b/src/xkbcomp/keymap.c @@ -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. */ diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c index d757a81..77766d2 100644 --- a/src/xkbcomp/rules.c +++ b/src/xkbcomp/rules.c @@ -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; diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index 1e044e5..b57d02c 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -1511,7 +1511,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry) } } - key->modmap |= (1 << entry->modifier); + key->modmap |= (1u << entry->modifier); return true; }