These are all trivial/obvious fixes which clear a bunch of warnings.
Signed-off-by: Ran Benita <ran234@gmail.com>
entry = &_XkeyTable[idx];
if ((entry[0] == sig1) && (entry[1] == sig2) &&
- !strcmp(s, (char *)entry + 6))
+ !strcmp(s, (const char *)entry + 6))
{
val = (entry[2] << 24) | (entry[3] << 16) |
(entry[4] << 8) | entry[5];
#define PART_MASK 0x000F
#define COMPONENT_MASK 0x03F0
-static char * cname[MAX_WORDS] = {
+static const char * cname[MAX_WORDS] = {
"model", "layout", "variant", "option",
"keycodes", "symbols", "types", "compat", "geometry", "keymap"
};
} FileSpec;
typedef struct {
- char * model;
- char * layout[XkbNumKbdGroups+1];
- char * variant[XkbNumKbdGroups+1];
+ const char * model;
+ const char * layout[XkbNumKbdGroups+1];
+ const char * variant[XkbNumKbdGroups+1];
char * options;
} XkbRF_MultiDefsRec, *XkbRF_MultiDefsPtr;
} else {
char *p;
int i;
- mdefs->layout[1] = _XkbDupString(defs->layout);
- if (mdefs->layout[1] == NULL)
- return False;
- squeeze_spaces(mdefs->layout[1]);
- p = mdefs->layout[1];
+ p = _XkbDupString(defs->layout);
+ if (p == NULL)
+ return False;
+ squeeze_spaces(p);
+ mdefs->layout[1] = p;
for (i = 2; i <= XkbNumKbdGroups; i++) {
if ((p = strchr(p, ','))) {
*p++ = '\0';
} else {
char *p;
int i;
- mdefs->variant[1] = _XkbDupString(defs->variant);
- if (mdefs->variant[1] == NULL)
- return False;
- squeeze_spaces(mdefs->variant[1]);
- p = mdefs->variant[1];
+ p = _XkbDupString(defs->variant);
+ if (p == NULL)
+ return False;
+ squeeze_spaces(p);
+ mdefs->variant[1] = p;
for (i = 2; i <= XkbNumKbdGroups; i++) {
if ((p = strchr(p, ','))) {
*p++ = '\0';
static void
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
{
- if (defs->options) free(defs->options);
- if (defs->layout[1]) free(defs->layout[1]);
- if (defs->variant[1]) free(defs->variant[1]);
+ if (defs->options)
+ free(defs->options);
+ /* Avoid -Wcast-qual warnings. */
+ if (defs->layout[1])
+ free((void *)(uintptr_t)defs->layout[1]);
+ if (defs->variant[1])
+ free((void *)(uintptr_t)defs->variant[1]);
}
static void
static Bool
CheckGroup( XkbRF_RulesPtr rules,
- char * group_name,
- char * name)
+ const char * group_name,
+ const char * name)
{
int i;
- char *p;
+ const char *p;
XkbRF_GroupPtr group;
for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) {
return rtrn;
}
-static char *
+static const char *
XkbcVModIndexText(struct xkb_desc * xkb, unsigned ndx)
{
int len;
return rtrn;
}
-char *
+const char *
XkbcVModMaskText(struct xkb_desc * xkb, unsigned modMask, unsigned mask)
{
int i, bit, len, rem;
- char *mm = NULL, *rtrn, *str;
+ const char *mm = NULL;
+ char *rtrn, *str;
char buf[BUFFER_SIZE];
if ((modMask == 0) && (mask == 0))
return rtrn;
}
-static char *modNames[XkbNumModifiers] = {
+static const char *modNames[XkbNumModifiers] = {
"Shift",
"Lock",
"Control",
"Mod5"
};
-char *
+const char *
XkbcModIndexText(unsigned ndx)
{
char *buf;
return buf;
}
-char *
+const char *
XkbcModMaskText(unsigned mask, Bool cFormat)
{
int i, rem, bit;
return buf;
}
-char *
+const char *
XkbcConfigText(unsigned config)
{
switch (config) {
}
}
-char *
+const char *
XkbcGeomFPText(int val)
{
char *buf;
return buf;
}
-static char *actionTypeNames[XkbSA_NumActions]= {
+static const char *actionTypeNames[XkbSA_NumActions]= {
"NoAction", /* XkbSA_NoAction */
"SetMods", /* XkbSA_SetMods */
"LatchMods", /* XkbSA_LatchMods */
"DeviceValuator" /* XkbSA_DeviceValuator */
};
-char *
+const char *
XkbcActionTypeText(unsigned type)
{
if (type <= XkbSA_LastAction)
return "Private";
}
-char *
+const char *
XkbcKeysymText(uint32_t sym)
{
static char buffer[16];
return buffer;
}
-char *
+const char *
XkbcKeyNameText(char *name)
{
char *buf;
return buf;
}
-static char *siMatchText[5] = {
+static const char *siMatchText[5] = {
"NoneOf", /* XkbSI_NoneOf */
"AnyOfOrNone", /* XkbSI_AnyOfOrNone */
"AnyOf", /* XkbSI_AnyOf */
"Exactly" /* XkbSI_Exactly */
};
-char *
+const char *
XkbcSIMatchText(unsigned type)
{
char *buf;
}
static Bool
-ReportNotFound(unsigned action, unsigned field, const char *what, char *bad)
+ReportNotFound(unsigned action, unsigned field, const char *what,
+ const char *bad)
{
ERROR("%s named %s not found\n", what, bad);
ACTION("Ignoring the %s field of an %s action\n", fieldText(field),
{
if (strncmp(a->alias, info->alias, XkbKeyNameLength) == 0)
{
- AliasInfo old;
- InitAliasInfo(&old, MergeAugment, 0, a->alias, a->real);
- HandleCollision(&old, info);
- memcpy(old.real, a->real, XkbKeyNameLength);
+ AliasInfo old_info;
+ InitAliasInfo(&old_info, MergeAugment, 0, a->alias, a->real);
+ HandleCollision(&old_info, info);
+ memcpy(old_info.real, a->real, XkbKeyNameLength);
info->alias[0] = '\0';
nNew--;
break;
ExprResult leftRtrn, rightRtrn;
ExprDef *left;
ExprDef *right;
- char *bogus = NULL;
+ const char *bogus = NULL;
switch (expr->op)
{
ExprResolveKeyName(ExprDef * expr,
ExprResult * val_rtrn)
{
- char *bogus = NULL;
+ const char *bogus = NULL;
switch (expr->op)
{
int ok = 0;
ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right;
- char *bogus = NULL;
+ const char *bogus = NULL;
switch (expr->op)
{
ExprResult tmp;
unsigned def;
unsigned type;
- char *typeName = "text doodad";
+ const char *typeName = "text doodad";
union
{
uint32_t *str;
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
ExprResult tmp;
- char *typeName = "logo doodad";
+ const char *typeName = "logo doodad";
if ((!uStrCaseCmp(field, "corner"))
|| (!uStrCaseCmp(field, "cornerradius")))
struct xkb_desc * xkb, unsigned merge, GeometryInfo * info)
{
ParseCommon *stmt;
- char *failWhat;
+ const char *failWhat;
if (merge == MergeDefault)
merge = MergeAugment;
#include "misc.h"
#include "alias.h"
-char *
+const char *
longText(unsigned long val)
{
char buf[4];
#define KeyNameToLong(n) ((((unsigned long)n[0])<<24)|(((unsigned long)n[1])<<16)|(((unsigned long)n[2])<<8)|n[3])
-extern char *longText(unsigned long /* val */
+extern const char *longText(unsigned long /* val */
);
extern void LongToKeyName(unsigned long /* val */ ,
}
if (report && (warningLevel > 0))
{
- char *str;
+ const char *str;
WARN("Multiple definitions for preserve[%s] in %s\n",
PreserveIndexTxt(xkb, old), TypeTxt(type));
static int
GenerateComponent(struct xkb_component_list * complist, unsigned type, char *head_in,
- char *base, int *max)
+ const char *base, int *max)
{
char *str, *head, *ptrn = NULL, *rest = NULL;
char buf[PATH_MAX];
extern int yylex(void);
extern int yyparse(void);
-extern void setScanState(char * /* file */ ,
+extern void setScanState(const char * /* file */ ,
int /* line */
);
geometry = CreateXKBFile(XkmGeometryIndex, NULL, (ParseCommon *)inc, 0);
AppendStmt(&keycodes->common, &geometry->common);
- return CreateXKBFile(XkmKeymapFile, ktcsg->keymap ? ktcsg->keymap : "",
+ return CreateXKBFile(XkmKeymapFile, ktcsg->keymap ? ktcsg->keymap : strdup(""),
&keycodes->common, 0);
}
}
if (!loaded) {
- rulesFile = XkbFindFileInPath((char *)rules, XkmRulesFile, &rulesPath);
+ rulesFile = XkbFindFileInPath(rules, XkmRulesFile, &rulesPath);
if (!rulesFile) {
ERROR("could not find \"%s\" rules in XKB path\n", rules);
goto out;
return NULL;
}
- defs.model = (char *) rmlvo->model;
- defs.layout = (char *) rmlvo->layout;
- defs.variant = (char *) rmlvo->variant;
- defs.options = (char *) rmlvo->options;
+ defs.model = rmlvo->model;
+ defs.layout = rmlvo->layout;
+ defs.variant = rmlvo->variant;
+ defs.options = rmlvo->options;
names = XkbComponentsFromRules(rmlvo->rules, &defs);
if (!names) {
* pathRtrn is undefined.
*/
FILE *
-XkbFindFileInPath(char *name, unsigned type, char **pathRtrn)
+XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
{
register int i;
FILE *file = NULL;
extern char *XkbDirectoryForInclude(unsigned /* type */
);
-extern FILE *XkbFindFileInPath(char * /* name */ ,
+extern FILE *XkbFindFileInPath(const char * /* name */ ,
unsigned /* type */ ,
char ** /* pathRtrn */
);
return;
}
-void setScanState(char *file, int lineno)
+void setScanState(const char *file, int lineno)
{
yylineno = 1;
if (scanFile)
extern const char *
XkbcAtomText(uint32_t atm);
-extern char *
+extern const char *
XkbcVModMaskText(struct xkb_desc * xkb, unsigned modMask, unsigned mask);
-extern char *
+extern const char *
XkbcModIndexText(unsigned ndx);
-extern char *
+extern const char *
XkbcModMaskText(unsigned mask, Bool cFormat);
-extern char *
+extern const char *
XkbcConfigText(unsigned config);
-extern char *
+extern const char *
XkbcGeomFPText(int val);
-extern char *
+extern const char *
XkbcActionTypeText(unsigned type);
-extern char *
+extern const char *
XkbcKeysymText(uint32_t sym);
-extern char *
+extern const char *
XkbcKeyNameText(char *name);
-extern char *
+extern const char *
XkbcSIMatchText(unsigned type);
#endif /* _XKBMISC_H_ */
#define _XkbErrBadImplementation 26
typedef struct _XkbRF_VarDefs {
- char * model;
- char * layout;
- char * variant;
- char * options;
+ const char * model;
+ const char * layout;
+ const char * variant;
+ const char * options;
unsigned short sz_extra;
unsigned short num_extra;
char * extra_names;