Fix all constness warnings

These are all trivial/obvious fixes which clear a bunch of warnings.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-02-24 16:07:17 +02:00
parent cca1c05097
commit f3e4335fc6
18 changed files with 79 additions and 73 deletions

View File

@ -114,7 +114,7 @@ xkb_string_to_keysym(const char *s)
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];

View File

@ -208,7 +208,7 @@ Bool endOfFile,spacePending,slashPending,inComment;
#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"
};
@ -228,9 +228,9 @@ typedef struct _FileSpec {
} 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;
@ -531,11 +531,11 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
} 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';
@ -555,11 +555,11 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
} 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';
@ -578,9 +578,13 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
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
@ -612,11 +616,11 @@ XkbRF_ApplyRule( XkbRF_RulePtr rule,
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++) {

View File

@ -55,7 +55,7 @@ tbGetBuffer(unsigned int size)
return rtrn;
}
static char *
static const char *
XkbcVModIndexText(struct xkb_desc * xkb, unsigned ndx)
{
int len;
@ -89,11 +89,12 @@ XkbcVModIndexText(struct xkb_desc * xkb, unsigned ndx)
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))
@ -138,7 +139,7 @@ XkbcVModMaskText(struct xkb_desc * xkb, unsigned modMask, unsigned mask)
return rtrn;
}
static char *modNames[XkbNumModifiers] = {
static const char *modNames[XkbNumModifiers] = {
"Shift",
"Lock",
"Control",
@ -149,7 +150,7 @@ static char *modNames[XkbNumModifiers] = {
"Mod5"
};
char *
const char *
XkbcModIndexText(unsigned ndx)
{
char *buf;
@ -165,7 +166,7 @@ XkbcModIndexText(unsigned ndx)
return buf;
}
char *
const char *
XkbcModMaskText(unsigned mask, Bool cFormat)
{
int i, rem, bit;
@ -198,7 +199,7 @@ XkbcModMaskText(unsigned mask, Bool cFormat)
return buf;
}
char *
const char *
XkbcConfigText(unsigned config)
{
switch (config) {
@ -228,7 +229,7 @@ XkbcConfigText(unsigned config)
}
}
char *
const char *
XkbcGeomFPText(int val)
{
char *buf;
@ -246,7 +247,7 @@ XkbcGeomFPText(int val)
return buf;
}
static char *actionTypeNames[XkbSA_NumActions]= {
static const char *actionTypeNames[XkbSA_NumActions]= {
"NoAction", /* XkbSA_NoAction */
"SetMods", /* XkbSA_SetMods */
"LatchMods", /* XkbSA_LatchMods */
@ -270,7 +271,7 @@ static char *actionTypeNames[XkbSA_NumActions]= {
"DeviceValuator" /* XkbSA_DeviceValuator */
};
char *
const char *
XkbcActionTypeText(unsigned type)
{
if (type <= XkbSA_LastAction)
@ -278,7 +279,7 @@ XkbcActionTypeText(unsigned type)
return "Private";
}
char *
const char *
XkbcKeysymText(uint32_t sym)
{
static char buffer[16];
@ -288,7 +289,7 @@ XkbcKeysymText(uint32_t sym)
return buffer;
}
char *
const char *
XkbcKeyNameText(char *name)
{
char *buf;
@ -305,7 +306,7 @@ XkbcKeyNameText(char *name)
return buf;
}
static char *siMatchText[5] = {
static const char *siMatchText[5] = {
"NoneOf", /* XkbSI_NoneOf */
"AnyOfOrNone", /* XkbSI_AnyOfOrNone */
"AnyOf", /* XkbSI_AnyOf */
@ -313,7 +314,7 @@ static char *siMatchText[5] = {
"Exactly" /* XkbSI_Exactly */
};
char *
const char *
XkbcSIMatchText(unsigned type)
{
char *buf;

View File

@ -323,7 +323,8 @@ ReportActionNotArray(unsigned action, unsigned field)
}
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),

View File

@ -213,10 +213,10 @@ ApplyAliases(struct xkb_desc * xkb, Bool toGeom, AliasInfo ** info_in)
{
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;

View File

@ -713,7 +713,7 @@ ExprResolveString(ExprDef * expr,
ExprResult leftRtrn, rightRtrn;
ExprDef *left;
ExprDef *right;
char *bogus = NULL;
const char *bogus = NULL;
switch (expr->op)
{
@ -795,7 +795,7 @@ int
ExprResolveKeyName(ExprDef * expr,
ExprResult * val_rtrn)
{
char *bogus = NULL;
const char *bogus = NULL;
switch (expr->op)
{
@ -893,7 +893,7 @@ ExprResolveMaskLookup(ExprDef * expr,
int ok = 0;
ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right;
char *bogus = NULL;
const char *bogus = NULL;
switch (expr->op)
{

View File

@ -1505,7 +1505,7 @@ SetTextDoodadField(DoodadInfo * di,
ExprResult tmp;
unsigned def;
unsigned type;
char *typeName = "text doodad";
const char *typeName = "text doodad";
union
{
uint32_t *str;
@ -1695,7 +1695,7 @@ SetLogoDoodadField(DoodadInfo * di,
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
ExprResult tmp;
char *typeName = "logo doodad";
const char *typeName = "logo doodad";
if ((!uStrCaseCmp(field, "corner"))
|| (!uStrCaseCmp(field, "cornerradius")))
@ -2859,7 +2859,7 @@ HandleGeometryFile(XkbFile * file,
struct xkb_desc * xkb, unsigned merge, GeometryInfo * info)
{
ParseCommon *stmt;
char *failWhat;
const char *failWhat;
if (merge == MergeDefault)
merge = MergeAugment;

View File

@ -32,7 +32,7 @@
#include "misc.h"
#include "alias.h"
char *
const char *
longText(unsigned long val)
{
char buf[4];

View File

@ -29,7 +29,7 @@
#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 */ ,

View File

@ -547,7 +547,7 @@ AddPreserve(struct xkb_desc * xkb,
}
if (report && (warningLevel > 0))
{
char *str;
const char *str;
WARN("Multiple definitions for preserve[%s] in %s\n",
PreserveIndexTxt(xkb, old), TypeTxt(type));

View File

@ -363,7 +363,7 @@ AddDirectory(CompPair *cp, char *head, char *ptrn, char *rest, char *map,
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];

View File

@ -183,7 +183,7 @@ extern void yyerror(const char * /* s */
extern int yylex(void);
extern int yyparse(void);
extern void setScanState(char * /* file */ ,
extern void setScanState(const char * /* file */ ,
int /* line */
);

View File

@ -68,7 +68,7 @@ XkbKeymapFileFromComponents(const struct xkb_component_names * ktcsg)
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);
}
@ -90,7 +90,7 @@ XkbComponentsFromRules(const char *rules, const XkbRF_VarDefsPtr defs)
}
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;
@ -146,10 +146,10 @@ xkb_compile_keymap_from_rules(const struct xkb_rule_names *rmlvo)
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) {

View File

@ -399,7 +399,7 @@ XkbFindFileInCache(char *name, unsigned type, char **pathRtrn)
* 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;

View File

@ -34,7 +34,7 @@
extern char *XkbDirectoryForInclude(unsigned /* type */
);
extern FILE *XkbFindFileInPath(char * /* name */ ,
extern FILE *XkbFindFileInPath(const char * /* name */ ,
unsigned /* type */ ,
char ** /* pathRtrn */
);

View File

@ -194,7 +194,7 @@ yyerror(const char *s)
return;
}
void setScanState(char *file, int lineno)
void setScanState(const char *file, int lineno)
{
yylineno = 1;
if (scanFile)

View File

@ -75,31 +75,31 @@ XkbcAtomGetString(uint32_t atom);
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_ */

View File

@ -74,10 +74,10 @@ authorization from the authors.
#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;