From a6410d61e5a3c2bfe949038de4e68f4450ef7767 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 16 Jun 2013 17:57:51 +0200 Subject: [PATCH] wmaker: Added 'const' attribute to local variables A number of these variable are not meant to be modified, so we show this to the compiler. Signed-off-by: Christophe CURIS --- src/WindowMaker.h | 4 ++-- src/defaults.c | 22 +++++++++++----------- src/dialog.c | 2 +- src/misc.c | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 100f75b5..23ea0469 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -263,9 +263,9 @@ typedef struct WObjDescriptor { /* notifications */ #ifdef MAINFILE -#define NOTIFICATION(n) char *WN##n = #n +#define NOTIFICATION(n) const char WN##n [] = #n #else -#define NOTIFICATION(n) extern char *WN##n +#define NOTIFICATION(n) extern const char WN##n [] #endif NOTIFICATION(WindowAppearanceSettingsChanged); diff --git a/src/defaults.c b/src/defaults.c index a1a4506a..601eb54d 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -84,8 +84,8 @@ typedef int (WDECallbackConvert) (WScreen *scr, WDefaultEntry *entry, WMPropList typedef int (WDECallbackUpdate) (WScreen *scr, WDefaultEntry *entry, void *tdata, void *extra_data); struct _WDefaultEntry { - char *key; - char *default_value; + const char *key; + const char *default_value; void *extra_data; void *addr; WDECallbackConvert *convert; @@ -96,7 +96,7 @@ struct _WDefaultEntry { /* used to map strings to integers */ typedef struct { - char *string; + const char *string; short value; char is_alias; } WOptionEnumeration; @@ -1295,7 +1295,7 @@ static int string2index(WMPropList *key, WMPropList *val, const char *def, WOpti static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret) { static char data; - char *val; + const char *val; int second_pass = 0; GET_STRING_OR_DEFAULT("Boolean", val); @@ -1338,7 +1338,7 @@ static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, voi static int getInt(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret) { static int data; - char *val; + const char *val; GET_STRING_OR_DEFAULT("Integer", val); @@ -2009,7 +2009,7 @@ getWSSpecificBackground(WScreen * scr, WDefaultEntry * entry, WMPropList * value static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret) { static WMFont *font; - char *val; + const char *val; GET_STRING_OR_DEFAULT("Font", val); @@ -2034,7 +2034,7 @@ static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, voi static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret) { static XColor color; - char *val; + const char *val; int second_pass = 0; GET_STRING_OR_DEFAULT("Color", val); @@ -2067,7 +2067,7 @@ static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, { static WShortKey shortcut; KeySym ksym; - char *val; + const char *val; char *k; char buf[MAX_SHORTCUT_LENGTH], *b; @@ -2124,7 +2124,7 @@ static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value, static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret) { static int mask; - char *str; + const char *str; GET_STRING_OR_DEFAULT("Modifier Key", str); @@ -2149,13 +2149,13 @@ static int getModMask(WScreen * scr, WDefaultEntry * entry, WMPropList * value, # include typedef struct { - char *name; + const char *name; int id; } WCursorLookup; #define CURSOR_ID_NONE (XC_num_glyphs) -static WCursorLookup cursor_table[] = { +static const WCursorLookup cursor_table[] = { {"X_cursor", XC_X_cursor}, {"arrow", XC_arrow}, {"based_arrow_down", XC_based_arrow_down}, diff --git a/src/dialog.c b/src/dialog.c index 5a529e1f..bef0985c 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -1121,7 +1121,7 @@ void wShowInfoPanel(WScreen * scr) char *strbuf = NULL; const char *separator; char buffer[256]; - char *name; + const char *name; Window parent; WWindow *wwin; char **strl; diff --git a/src/misc.c b/src/misc.c index 6c21aa9e..b2f40f6b 100644 --- a/src/misc.c +++ b/src/misc.c @@ -167,7 +167,7 @@ void SlideWindows(Window *wins[], int n, int from_x, int from_y, int to_x, int t int i; /* animation parameters */ - static struct { + static const struct { int delay; int steps; int slowdown; -- 2.11.4.GIT