Fix all -Wsign-compare warnings

i.e comparison of signed and unsigned values. These are mostly
harmless but fixing them allows to compile cleanly with -Wextra.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-03-24 02:36:11 +02:00 committed by Daniel Stone
parent 813ddf255d
commit 2165e16ed9
14 changed files with 60 additions and 54 deletions

View File

@ -99,7 +99,7 @@ XkbcFreeCompatMap(struct xkb_desc * xkb)
} }
int int
XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalAliases) XkbcAllocNames(struct xkb_desc * xkb, unsigned which, unsigned nTotalAliases)
{ {
struct xkb_names * names; struct xkb_names * names;

View File

@ -121,7 +121,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
int int
XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions) XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
{ {
int i; unsigned i;
struct xkb_server_map * map; struct xkb_server_map * map;
if (!xkb) if (!xkb)
@ -166,7 +166,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
map->num_acts = 1; map->num_acts = 1;
map->size_acts = nNewActions + 1; map->size_acts = nNewActions + 1;
} }
else if ((map->size_acts - map->num_acts) < nNewActions) { else if ((map->size_acts - map->num_acts) < (int)nNewActions) {
unsigned need; unsigned need;
union xkb_action *prev_acts = map->acts; union xkb_action *prev_acts = map->acts;
@ -298,7 +298,7 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
newSyms[0] = NoSymbol; newSyms[0] = NoSymbol;
nSyms = 1; nSyms = 1;
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) { for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
int nCopy; uint32_t nCopy;
nCopy = nKeySyms = XkbKeyNumSyms(xkb, i); nCopy = nKeySyms = XkbKeyNumSyms(xkb, i);
if ((nKeySyms == 0) && (i != key)) if ((nKeySyms == 0) && (i != key))
@ -325,7 +325,7 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
} }
union xkb_action * union xkb_action *
XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed) XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, uint32_t needed)
{ {
xkb_keycode_t i, nActs; xkb_keycode_t i, nActs;
union xkb_action *newActs; union xkb_action *newActs;
@ -336,10 +336,10 @@ XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed)
} }
if (XkbKeyHasActions(xkb, key) && if (XkbKeyHasActions(xkb, key) &&
(XkbKeyNumSyms(xkb, key) >= (unsigned)needed)) (XkbKeyNumSyms(xkb, key) >= (int)needed))
return XkbKeyActionsPtr(xkb, key); return XkbKeyActionsPtr(xkb, key);
if (xkb->server->size_acts - xkb->server->num_acts >= (unsigned)needed) { if (xkb->server->size_acts - xkb->server->num_acts >= (int)needed) {
xkb->server->key_acts[key] = xkb->server->num_acts; xkb->server->key_acts[key] = xkb->server->num_acts;
xkb->server->num_acts += needed; xkb->server->num_acts += needed;

View File

@ -275,7 +275,7 @@ xkb_key_get_group(struct xkb_state *state, xkb_keycode_t key)
{ {
unsigned int info = XkbKeyGroupInfo(state->xkb, key); unsigned int info = XkbKeyGroupInfo(state->xkb, key);
unsigned int num_groups = XkbKeyNumGroups(state->xkb, key); unsigned int num_groups = XkbKeyNumGroups(state->xkb, key);
int ret = state->group; unsigned int ret = state->group;
if (ret < XkbKeyNumGroups(state->xkb, key)) if (ret < XkbKeyNumGroups(state->xkb, key))
return ret; return ret;

View File

@ -263,7 +263,8 @@ SetUpRemap(InputLine *line,RemapSpec *remap)
char *tok, *str; char *tok, *str;
unsigned present, l_ndx_present, v_ndx_present; unsigned present, l_ndx_present, v_ndx_present;
int i; int i;
int len, ndx; size_t len;
int ndx;
_Xstrtokparams strtok_buf; _Xstrtokparams strtok_buf;
#ifdef DEBUG #ifdef DEBUG
Bool found; Bool found;
@ -727,7 +728,7 @@ static void
XkbRF_CheckApplyRules( XkbRF_RulesPtr rules, XkbRF_CheckApplyRules( XkbRF_RulesPtr rules,
XkbRF_MultiDefsPtr mdefs, XkbRF_MultiDefsPtr mdefs,
struct xkb_component_names * names, struct xkb_component_names * names,
int flags) unsigned int flags)
{ {
int i; int i;
XkbRF_RulePtr rule; XkbRF_RulePtr rule;
@ -751,7 +752,8 @@ static char *
XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs) XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs)
{ {
char *str, *outstr, *orig, *var; char *str, *outstr, *orig, *var;
int len, ndx; size_t len;
int ndx;
orig= name; orig= name;
str= strchr(name,'%'); str= strchr(name,'%');

View File

@ -36,7 +36,7 @@
#define BUFFER_SIZE 1024 #define BUFFER_SIZE 1024
static char textBuffer[BUFFER_SIZE]; static char textBuffer[BUFFER_SIZE];
static int tbNext = 0; static unsigned int tbNext = 0;
static char * static char *
tbGetBuffer(unsigned int size) tbGetBuffer(unsigned int size)

View File

@ -36,7 +36,7 @@ extern int
XkbcAllocCompatMap(struct xkb_desc * xkb, unsigned which, unsigned nSI); XkbcAllocCompatMap(struct xkb_desc * xkb, unsigned which, unsigned nSI);
extern int extern int
XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalAliases); XkbcAllocNames(struct xkb_desc * xkb, unsigned which, unsigned nTotalAliases);
extern int extern int
XkbcAllocControls(struct xkb_desc * xkb, unsigned which); XkbcAllocControls(struct xkb_desc * xkb, unsigned which);
@ -65,7 +65,7 @@ extern xkb_keysym_t *
XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key, uint32_t needed); XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key, uint32_t needed);
extern union xkb_action * extern union xkb_action *
XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed); XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, uint32_t needed);
extern void extern void
XkbcFreeClientMap(struct xkb_desc * xkb); XkbcFreeClientMap(struct xkb_desc * xkb);

View File

@ -102,7 +102,7 @@ siText(SymInterpInfo * si, CompatInfo * info)
static void static void
InitCompatInfo(CompatInfo * info, struct xkb_desc * xkb) InitCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
{ {
int i; unsigned int i;
info->xkb = xkb; info->xkb = xkb;
info->name = NULL; info->name = NULL;
@ -132,7 +132,7 @@ InitCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
static void static void
ClearCompatInfo(CompatInfo * info, struct xkb_desc * xkb) ClearCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
{ {
int i; unsigned int i;
ActionInfo *next; ActionInfo *next;
free(info->name); free(info->name);

View File

@ -351,7 +351,7 @@ InitKeyNamesInfo(KeyNamesInfo * info)
static int static int
FindKeyByLong(KeyNamesInfo * info, unsigned long name) FindKeyByLong(KeyNamesInfo * info, unsigned long name)
{ {
int i; uint64_t i;
for (i = info->computedMin; i <= info->computedMax; i++) for (i = info->computedMin; i <= info->computedMax; i++)
{ {
@ -371,7 +371,7 @@ AddKeyName(KeyNamesInfo * info,
xkb_keycode_t kc, xkb_keycode_t kc,
char *name, unsigned merge, unsigned fileID, Bool reportCollisions) char *name, unsigned merge, unsigned fileID, Bool reportCollisions)
{ {
int old; xkb_keycode_t old;
unsigned long lval; unsigned long lval;
if (kc > info->arraySize && !ResizeKeyNameArrays(info, kc)) { if (kc > info->arraySize && !ResizeKeyNameArrays(info, kc)) {
@ -474,7 +474,7 @@ static void
MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from, MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
unsigned merge) unsigned merge)
{ {
int i; uint64_t i;
char buf[5]; char buf[5];
if (from->errorCount > 0) if (from->errorCount > 0)
@ -549,9 +549,11 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
{ {
unsigned newMerge; unsigned newMerge;
XkbFile *rtrn; XkbFile *rtrn;
KeyNamesInfo included = {NULL}; KeyNamesInfo included;
Bool haveSelf; Bool haveSelf;
memset(&included, 0, sizeof(included));
haveSelf = False; haveSelf = False;
if ((stmt->file == NULL) && (stmt->map == NULL)) if ((stmt->file == NULL) && (stmt->map == NULL))
{ {
@ -894,7 +896,7 @@ CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
if (XkbcAllocNames(xkb, XkbKeyNamesMask | XkbIndicatorNamesMask, 0) if (XkbcAllocNames(xkb, XkbKeyNamesMask | XkbIndicatorNamesMask, 0)
== Success) == Success)
{ {
int i; uint64_t i;
for (i = info.computedMin; i <= info.computedMax; i++) for (i = info.computedMin; i <= info.computedMax; i++)
LongToKeyName(info.names[i], xkb->names->keys[i].name); LongToKeyName(info.names[i], xkb->names->keys[i].name);
} }

View File

@ -57,12 +57,12 @@ typedef struct _KeyTypeInfo
unsigned mask; unsigned mask;
unsigned vmask; unsigned vmask;
Bool groupInfo; Bool groupInfo;
int numLevels; unsigned numLevels;
int nEntries; unsigned nEntries;
int szEntries; unsigned szEntries;
struct xkb_kt_map_entry * entries; struct xkb_kt_map_entry * entries;
PreserveInfo *preserve; PreserveInfo *preserve;
int szNames; unsigned szNames;
xkb_atom_t *lvlNames; xkb_atom_t *lvlNames;
} KeyTypeInfo; } KeyTypeInfo;
@ -72,7 +72,7 @@ typedef struct _KeyTypesInfo
int errorCount; int errorCount;
int fileID; int fileID;
unsigned stdPresent; unsigned stdPresent;
int nTypes; unsigned nTypes;
KeyTypeInfo *types; KeyTypeInfo *types;
KeyTypeInfo dflt; KeyTypeInfo dflt;
VModInfo vmods; VModInfo vmods;
@ -445,7 +445,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
static struct xkb_kt_map_entry * static struct xkb_kt_map_entry *
FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask) FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
{ {
int i; unsigned int i;
struct xkb_kt_map_entry * entry; struct xkb_kt_map_entry * entry;
for (i = 0, entry = type->entries; i < type->nEntries; i++, entry++) for (i = 0, entry = type->entries; i < type->nEntries; i++, entry++)
@ -459,7 +459,7 @@ FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
static void static void
DeleteLevel1MapEntries(KeyTypeInfo * type) DeleteLevel1MapEntries(KeyTypeInfo * type)
{ {
int i, n; unsigned int i, n;
for (i = 0; i < type->nEntries; i++) for (i = 0; i < type->nEntries; i++)
{ {
@ -929,7 +929,7 @@ static int
HandleKeyTypeDef(KeyTypeDef * def, HandleKeyTypeDef(KeyTypeDef * def,
struct xkb_desc * xkb, unsigned merge, KeyTypesInfo * info) struct xkb_desc * xkb, unsigned merge, KeyTypesInfo * info)
{ {
int i; unsigned int i;
KeyTypeInfo type; KeyTypeInfo type;
if (def->merge != MergeDefault) if (def->merge != MergeDefault)
@ -1070,7 +1070,7 @@ HandleKeyTypesFile(XkbFile * file,
static Bool static Bool
CopyDefToKeyType(struct xkb_desc * xkb, struct xkb_key_type * type, KeyTypeInfo * def) CopyDefToKeyType(struct xkb_desc * xkb, struct xkb_key_type * type, KeyTypeInfo * def)
{ {
int i; unsigned int i;
PreserveInfo *pre; PreserveInfo *pre;
for (pre = def->preserve; pre != NULL; for (pre = def->preserve; pre != NULL;
@ -1151,7 +1151,7 @@ CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
if (info.errorCount == 0) if (info.errorCount == 0)
{ {
int i; unsigned int i;
KeyTypeInfo *def; KeyTypeInfo *def;
struct xkb_key_type *type, *next; struct xkb_key_type *type, *next;

View File

@ -250,7 +250,7 @@ Bool
FindNamedKey(struct xkb_desc * xkb, FindNamedKey(struct xkb_desc * xkb,
unsigned long name, unsigned long name,
xkb_keycode_t *kc_rtrn, xkb_keycode_t *kc_rtrn,
Bool use_aliases, Bool create, int start_from) Bool use_aliases, Bool create, xkb_keycode_t start_from)
{ {
unsigned n; unsigned n;
@ -318,7 +318,7 @@ Bool
FindKeyNameForAlias(struct xkb_desc * xkb, unsigned long lname, FindKeyNameForAlias(struct xkb_desc * xkb, unsigned long lname,
unsigned long *real_name) unsigned long *real_name)
{ {
int i; unsigned int i;
char name[XkbKeyNameLength + 1]; char name[XkbKeyNameLength + 1];
if (xkb && xkb->names && xkb->names->key_aliases) if (xkb && xkb->names && xkb->names->key_aliases)

View File

@ -80,7 +80,7 @@ extern Bool FindNamedKey(struct xkb_desc * /* xkb */ ,
xkb_keycode_t * /* kc_rtrn */ , xkb_keycode_t * /* kc_rtrn */ ,
Bool /* use_aliases */ , Bool /* use_aliases */ ,
Bool /* create */ , Bool /* create */ ,
int /* start_from */ xkb_keycode_t /* start_from */
); );
extern Bool FindKeyNameForAlias(struct xkb_desc * /* xkb */ , extern Bool FindKeyNameForAlias(struct xkb_desc * /* xkb */ ,

View File

@ -63,7 +63,7 @@ typedef struct _KeyInfo
unsigned char typesDefined; unsigned char typesDefined;
unsigned char symsDefined; unsigned char symsDefined;
unsigned char actsDefined; unsigned char actsDefined;
short numLevels[XkbNumKbdGroups]; unsigned int numLevels[XkbNumKbdGroups];
xkb_keysym_t *syms[XkbNumKbdGroups]; xkb_keysym_t *syms[XkbNumKbdGroups];
union xkb_action *acts[XkbNumKbdGroups]; union xkb_action *acts[XkbNumKbdGroups];
xkb_atom_t types[XkbNumKbdGroups]; xkb_atom_t types[XkbNumKbdGroups];
@ -159,7 +159,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
} }
else else
{ {
int width; unsigned int width;
for (i = 0; i < XkbNumKbdGroups; i++) for (i = 0; i < XkbNumKbdGroups; i++)
{ {
width = new->numLevels[i]; width = new->numLevels[i];
@ -252,7 +252,7 @@ InitSymbolsInfo(SymbolsInfo * info, struct xkb_desc * xkb)
static void static void
FreeSymbolsInfo(SymbolsInfo * info) FreeSymbolsInfo(SymbolsInfo * info)
{ {
int i; unsigned int i;
free(info->name); free(info->name);
if (info->keys) if (info->keys)
@ -308,8 +308,8 @@ MergeKeyGroups(SymbolsInfo * info,
{ {
xkb_keysym_t *resultSyms; xkb_keysym_t *resultSyms;
union xkb_action *resultActs; union xkb_action *resultActs;
int resultWidth; unsigned int resultWidth;
int i; unsigned int i;
Bool report, clobber; Bool report, clobber;
clobber = (from->defs.merge != MergeAugment); clobber = (from->defs.merge != MergeAugment);
@ -576,7 +576,7 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
static Bool static Bool
AddKeySymbols(SymbolsInfo * info, KeyInfo * key, struct xkb_desc * xkb) AddKeySymbols(SymbolsInfo * info, KeyInfo * key, struct xkb_desc * xkb)
{ {
int i; unsigned int i;
unsigned long real_name; unsigned long real_name;
for (i = 0; i < info->nKeys; i++) for (i = 0; i < info->nKeys; i++)
@ -688,7 +688,7 @@ static void
MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from, MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
unsigned merge, struct xkb_desc * xkb) unsigned merge, struct xkb_desc * xkb)
{ {
int i; unsigned int i;
KeyInfo *key; KeyInfo *key;
if (from->errorCount > 0) if (from->errorCount > 0)
@ -887,7 +887,8 @@ AddSymbolsToKey(KeyInfo * key,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info) ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{ {
unsigned ndx, nSyms; unsigned ndx, nSyms;
int i; unsigned int i;
long j;
if (!GetGroupIndex(key, arrayNdx, SYMBOLS, &ndx)) if (!GetGroupIndex(key, arrayNdx, SYMBOLS, &ndx))
return False; return False;
@ -928,8 +929,8 @@ AddSymbolsToKey(KeyInfo * key,
key->syms[ndx][i] = NoSymbol; key->syms[ndx][i] = NoSymbol;
} }
} }
for (i = key->numLevels[ndx] - 1; for (j = key->numLevels[ndx] - 1;
(i >= 0) && (key->syms[ndx][i] == NoSymbol); i--) (j >= 0) && (key->syms[ndx][j] == NoSymbol); j--)
{ {
key->numLevels[ndx]--; key->numLevels[ndx]--;
} }
@ -942,7 +943,7 @@ AddActionsToKey(KeyInfo * key,
char *field, char *field,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info) ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{ {
int i; unsigned int i;
unsigned ndx, nActs; unsigned ndx, nActs;
ExprDef *act; ExprDef *act;
struct xkb_any_action *toAct; struct xkb_any_action *toAct;
@ -1738,7 +1739,7 @@ PrepareKeyDef(KeyInfo * key)
static Bool static Bool
CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from) CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
{ {
int i; unsigned int i;
xkb_keycode_t kc; xkb_keycode_t kc;
unsigned width, tmp, nGroups; unsigned width, tmp, nGroups;
struct xkb_key_type * type; struct xkb_key_type * type;
@ -1966,7 +1967,7 @@ CopyModMapDef(struct xkb_desc * xkb, ModMapEntry *entry)
Bool Bool
CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge) CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
{ {
int i; unsigned int i;
SymbolsInfo info; SymbolsInfo info;
InitSymbolsInfo(&info, xkb); InitSymbolsInfo(&info, xkb);

View File

@ -246,7 +246,7 @@ typedef struct _IndicatorMapDef
typedef struct _XkbFile typedef struct _XkbFile
{ {
ParseCommon common; ParseCommon common;
int type; unsigned type;
char *topName; char *topName;
char *name; char *name;
ParseCommon *defs; ParseCommon *defs;

View File

@ -44,9 +44,9 @@
static Bool noDefaultPath = False; static Bool noDefaultPath = False;
/* number of entries allocated for includePath */ /* number of entries allocated for includePath */
static int szPath; static size_t szPath;
/* number of actual entries in includePath */ /* number of actual entries in includePath */
static int nPathEntries; static size_t nPathEntries;
/* Holds all directories we might be including data from */ /* Holds all directories we might be including data from */
static char **includePath = NULL; static char **includePath = NULL;
@ -184,7 +184,7 @@ XkbInitIncludePath(void)
static void static void
XkbClearIncludePath(void) XkbClearIncludePath(void)
{ {
int i; size_t i;
if (szPath > 0) if (szPath > 0)
{ {
@ -249,7 +249,7 @@ XkbAddDirectoryToPath(const char *dir)
includePath[nPathEntries] = strdup(dir); includePath[nPathEntries] = strdup(dir);
if (includePath[nPathEntries] == NULL) if (includePath[nPathEntries] == NULL)
{ {
WSGO("Allocation failed (includePath[%d])\n", nPathEntries); WSGO("Allocation failed (includePath[%zd])\n", nPathEntries);
return False; return False;
} }
nPathEntries++; nPathEntries++;
@ -315,7 +315,8 @@ XkbDirectoryForInclude(unsigned type)
FILE * FILE *
XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn) XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
{ {
int i, ret; size_t i;
int ret;
FILE *file = NULL; FILE *file = NULL;
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *typeDir; const char *typeDir;
@ -331,7 +332,7 @@ XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
ret = snprintf(buf, sizeof(buf), "%s/%s/%s", ret = snprintf(buf, sizeof(buf), "%s/%s/%s",
includePath[i], typeDir, name); includePath[i], typeDir, name);
if (ret >= sizeof(buf)) if (ret >= (ssize_t)sizeof(buf))
{ {
ERROR("File name (%s/%s/%s) too long\n", includePath[i], ERROR("File name (%s/%s/%s) too long\n", includePath[i],
typeDir, name); typeDir, name);