From 6db8fd556e2562e9a0a821c0d6fd4f7cdcf6266c Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 11 Dec 2022 15:18:26 -0800 Subject: Mark more pointers as const Some suggested by cppcheck, others by manual code inspection Signed-off-by: Alan Coopersmith --- xkbcomp.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'xkbcomp.c') diff --git a/xkbcomp.c b/xkbcomp.c index 1be264d..6aedb67 100644 --- a/xkbcomp.c +++ b/xkbcomp.c @@ -80,12 +80,12 @@ static const char *fileTypeExt[] = { }; static unsigned inputFormat, outputFormat; -static char *rootDir; +static const char *rootDir; static char *inputFile; -static char *inputMap; +static const char *inputMap; static char *outputFile; -static char *inDpyName; -static char *outDpyName; +static const char *inDpyName; +static const char *outDpyName; static Display *inDpy; static Display *outDpy; static Bool showImplicit = False; @@ -96,9 +96,9 @@ unsigned warningLevel = 5; unsigned verboseLevel = 0; unsigned dirsToStrip = 0; static unsigned optionalParts = 0; -static char *preErrorMsg = NULL; -static char *postErrorMsg = NULL; -static char *errorPrefix = NULL; +static const char *preErrorMsg = NULL; +static const char *postErrorMsg = NULL; +static const char *errorPrefix = NULL; static unsigned int device_id = XkbUseCoreKbd; /***====================================================================***/ @@ -177,7 +177,7 @@ Usage(int argc, char *argv[]) /***====================================================================***/ static void -setVerboseFlags(char *str) +setVerboseFlags(const char *str) { for (; *str; str++) { @@ -464,7 +464,7 @@ parseArgs(int argc, char *argv[]) } else { - for (char *tmp2 = argv[i]; (*tmp2 != '\0'); tmp2++) + for (const char *tmp2 = argv[i]; (*tmp2 != '\0'); tmp2++) { switch (*tmp2) { @@ -565,7 +565,7 @@ parseArgs(int argc, char *argv[]) } else if (strncmp(argv[i], "-v", 2) == 0) { - char *str; + const char *str; if (argv[i][2] != '\0') str = &argv[i][2]; else if ((i < (argc - 1)) && (argv[i + 1][0] != '-')) @@ -776,7 +776,7 @@ parseArgs(int argc, char *argv[]) else if ((outputFile == NULL) && (inputFile != NULL)) { int len; - char *base, *ext; + const char *base, *ext; if (inputMap == NULL) { @@ -809,9 +809,10 @@ parseArgs(int argc, char *argv[]) else if (outputFile == NULL) { int len; - char *ch, *name, buf[128]; + char *ch, buf[128]; + const char *name = buf; if (inDpyName[0] == ':') - snprintf(name = buf, sizeof(buf), "server%s", inDpyName); + snprintf(buf, sizeof(buf), "server%s", inDpyName); else name = inDpyName; @@ -851,7 +852,7 @@ parseArgs(int argc, char *argv[]) } static Display * -GetDisplay(char *program, char *dpyName) +GetDisplay(const char *program, const char *dpyName) { int mjr, mnr, error; Display *dpy; -- cgit v1.2.3