summaryrefslogtreecommitdiff
path: root/xkb
diff options
context:
space:
mode:
authorMikhail Gusarov <dottedmag@dottedmag.net>2010-06-06 15:28:30 +0700
committerMikhail Gusarov <dottedmag@dottedmag.net>2010-06-06 20:27:18 +0700
commit0a4d8cbdcd7b25313fb29ccdb498044af95f7de6 (patch)
tree3534c9035180b7e0d2ebbbf0202a370cb61f8e8d /xkb
parent5a0fc0ad21d562612676ef88ef2d533b2391810a (diff)
Remove more superfluous if(p) checks around free(p)
This patch has been generated by the following Coccinelle semantic patch: @@ expression E; @@ -if(E) { free(E); } +free(E); Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br> Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'xkb')
-rw-r--r--xkb/XKBGAlloc.c6
-rw-r--r--xkb/XKBMAlloc.c9
-rw-r--r--xkb/maprules.c28
-rw-r--r--xkb/xkbInit.c30
-rw-r--r--xkb/xkbLEDs.c4
5 files changed, 31 insertions, 46 deletions
diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c
index f155cc867..796931cf4 100644
--- a/xkb/XKBGAlloc.c
+++ b/xkb/XKBGAlloc.c
@@ -183,8 +183,7 @@ _XkbClearColor(char *color_in)
{
XkbColorPtr color= (XkbColorPtr)color_in;
- if (color->spec)
- free(color->spec);
+ free(color->spec);
return;
}
@@ -663,8 +662,7 @@ register XkbPropertyPtr prop;
return NULL;
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
- if (prop->value)
- free(prop->value);
+ free(prop->value);
prop->value= malloc(strlen(value)+1);
if (prop->value)
strcpy(prop->value,value);
diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c
index abe001856..197523f57 100644
--- a/xkb/XKBMAlloc.c
+++ b/xkb/XKBMAlloc.c
@@ -312,8 +312,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
if ((map_count>type->map_count)||(type->map==NULL))
type->map = realloc(type->map,map_count * sizeof(XkbKTMapEntryRec));
if (!type->map) {
- if (prev_map)
- free(prev_map);
+ free(prev_map);
return BadAlloc;
}
if (want_preserve) {
@@ -324,8 +323,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
map_count * sizeof(XkbModsRec));
}
if (!type->preserve) {
- if (prev_preserve)
- free(prev_preserve);
+ free(prev_preserve);
return BadAlloc;
}
}
@@ -342,8 +340,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
type->level_names = realloc(type->level_names,
new_num_lvls * sizeof(Atom));
if (!type->level_names) {
- if (prev_level_names)
- free(prev_level_names);
+ free(prev_level_names);
return BadAlloc;
}
}
diff --git a/xkb/maprules.c b/xkb/maprules.c
index 5aabd1c8e..c683c0d4f 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -553,9 +553,9 @@ 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]);
+ free(defs->options);
+ free(defs->layout[1]);
+ free(defs->variant[1]);
}
static void
@@ -988,15 +988,15 @@ XkbRF_GroupPtr group;
return;
if (rules->rules) {
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
- if (rule->model) free(rule->model);
- if (rule->layout) free(rule->layout);
- if (rule->variant) free(rule->variant);
- if (rule->option) free(rule->option);
- if (rule->keycodes) free(rule->keycodes);
- if (rule->symbols) free(rule->symbols);
- if (rule->types) free(rule->types);
- if (rule->compat) free(rule->compat);
- if (rule->geometry) free(rule->geometry);
+ free(rule->model);
+ free(rule->layout);
+ free(rule->variant);
+ free(rule->option);
+ free(rule->keycodes);
+ free(rule->symbols);
+ free(rule->types);
+ free(rule->compat);
+ free(rule->geometry);
memset((char *)rule, 0, sizeof(XkbRF_RuleRec));
}
free(rules->rules);
@@ -1006,8 +1006,8 @@ XkbRF_GroupPtr group;
if (rules->groups) {
for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
- if (group->name) free(group->name);
- if (group->words) free(group->words);
+ free(group->name);
+ free(group->words);
}
free(rules->groups);
rules->num_groups= 0;
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 0f3ffa468..bd58243ca 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -220,20 +220,15 @@ char * pval;
static void
XkbSetRulesUsed(XkbRMLVOSet *rmlvo)
{
- if (XkbRulesUsed)
- free(XkbRulesUsed);
+ free(XkbRulesUsed);
XkbRulesUsed= (rmlvo->rules?_XkbDupString(rmlvo->rules):NULL);
- if (XkbModelUsed)
- free(XkbModelUsed);
+ free(XkbModelUsed);
XkbModelUsed= (rmlvo->model?_XkbDupString(rmlvo->model):NULL);
- if (XkbLayoutUsed)
- free(XkbLayoutUsed);
+ free(XkbLayoutUsed);
XkbLayoutUsed= (rmlvo->layout?_XkbDupString(rmlvo->layout):NULL);
- if (XkbVariantUsed)
- free(XkbVariantUsed);
+ free(XkbVariantUsed);
XkbVariantUsed= (rmlvo->variant?_XkbDupString(rmlvo->variant):NULL);
- if (XkbOptionsUsed)
- free(XkbOptionsUsed);
+ free(XkbOptionsUsed);
XkbOptionsUsed= (rmlvo->options?_XkbDupString(rmlvo->options):NULL);
if (XkbWantRulesProp)
QueueWorkProc(XkbWriteRulesProp,NULL,NULL);
@@ -244,28 +239,23 @@ void
XkbSetRulesDflts(XkbRMLVOSet *rmlvo)
{
if (rmlvo->rules) {
- if (XkbRulesDflt)
- free(XkbRulesDflt);
+ free(XkbRulesDflt);
XkbRulesDflt= _XkbDupString(rmlvo->rules);
}
if (rmlvo->model) {
- if (XkbModelDflt)
- free(XkbModelDflt);
+ free(XkbModelDflt);
XkbModelDflt= _XkbDupString(rmlvo->model);
}
if (rmlvo->layout) {
- if (XkbLayoutDflt)
- free(XkbLayoutDflt);
+ free(XkbLayoutDflt);
XkbLayoutDflt= _XkbDupString(rmlvo->layout);
}
if (rmlvo->variant) {
- if (XkbVariantDflt)
- free(XkbVariantDflt);
+ free(XkbVariantDflt);
XkbVariantDflt= _XkbDupString(rmlvo->variant);
}
if (rmlvo->options) {
- if (XkbOptionsDflt)
- free(XkbOptionsDflt);
+ free(XkbOptionsDflt);
XkbOptionsDflt= _XkbDupString(rmlvo->options);
}
return;
diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c
index d75f92093..ae3666f3f 100644
--- a/xkb/xkbLEDs.c
+++ b/xkb/xkbLEDs.c
@@ -605,8 +605,8 @@ void
XkbFreeSrvLedInfo(XkbSrvLedInfoPtr sli)
{
if ((sli->flags&XkbSLI_IsDefault)==0) {
- if (sli->maps) free(sli->maps);
- if (sli->names) free(sli->names);
+ free(sli->maps);
+ free(sli->names);
}
sli->maps= NULL;
sli->names= NULL;