[PATCH 3/7] Fix gcc -Wwrite-strings warnings in XkbGetRulesDflts

Alan Coopersmith alan.coopersmith at oracle.com
Tue Nov 8 12:42:51 PST 2011


Stop temporarily storing a pointer to a constant literal string
in a char *, just to strdup it a few lines later.

Fixes gcc -Wwrite-strings warnings:

xkbInit.c: In function 'XkbGetRulesDflts':
xkbInit.c:121:38: warning: assignment discards qualifiers from pointer target type
xkbInit.c:123:23: warning: assignment discards qualifiers from pointer target type
xkbInit.c:125:24: warning: assignment discards qualifiers from pointer target type
xkbInit.c:127:25: warning: assignment discards qualifiers from pointer target type
xkbInit.c:129:25: warning: assignment discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 xkb/xkbInit.c |   21 +++++----------------
 1 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 1ec4e55..f578f16 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -117,22 +117,11 @@ static Bool		XkbWantRulesProp=	XKB_DFLT_RULES_PROP;
 void
 XkbGetRulesDflts(XkbRMLVOSet *rmlvo)
 {
-    if (XkbRulesDflt)   rmlvo->rules = XkbRulesDflt;
-    else                rmlvo->rules = XKB_DFLT_RULES;
-    if (XkbModelDflt)	rmlvo->model= XkbModelDflt;
-    else		rmlvo->model= XKB_DFLT_MODEL;
-    if (XkbLayoutDflt)	rmlvo->layout= XkbLayoutDflt;
-    else		rmlvo->layout= XKB_DFLT_LAYOUT;
-    if (XkbVariantDflt)	rmlvo->variant= XkbVariantDflt;
-    else		rmlvo->variant= XKB_DFLT_VARIANT;
-    if (XkbOptionsDflt)	rmlvo->options= XkbOptionsDflt;
-    else		rmlvo->options= XKB_DFLT_OPTIONS;
-
-    rmlvo->rules = strdup(rmlvo->rules);
-    rmlvo->model = strdup(rmlvo->model);
-    rmlvo->layout = strdup(rmlvo->layout);
-    rmlvo->variant = strdup(rmlvo->variant);
-    rmlvo->options = strdup(rmlvo->options);
+    rmlvo->rules  = strdup(XkbRulesDflt   ? XkbRulesDflt   : XKB_DFLT_RULES);
+    rmlvo->model  = strdup(XkbModelDflt   ? XkbModelDflt   : XKB_DFLT_MODEL);
+    rmlvo->layout = strdup(XkbLayoutDflt  ? XkbLayoutDflt  : XKB_DFLT_LAYOUT);
+    rmlvo->variant= strdup(XkbVariantDflt ? XkbVariantDflt : XKB_DFLT_VARIANT);
+    rmlvo->options= strdup(XkbOptionsDflt ? XkbOptionsDflt : XKB_DFLT_OPTIONS);
 }
 
 void
-- 
1.7.3.2



More information about the xorg-devel mailing list