summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-10 14:23:11 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-11 15:36:06 -0800
commit5655379ce89ab55f25a536972aaa310480de9432 (patch)
treeaa9cffb76485caf32da96d8d689f5a0ce6ab6c11
parent2ac6a7f029d8855fbb4e8024aab0511727ac3a67 (diff)
downloadxorg-app-xkbcomp-5655379ce89ab55f25a536972aaa310480de9432.tar.gz
Remove unnecessary checks for NULL pointers before calling free()
Not needed in C89 and later Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--compat.c9
-rw-r--r--geometry.c15
-rw-r--r--keycodes.c6
-rw-r--r--keytypes.c22
-rw-r--r--parseutils.c14
-rw-r--r--symbols.c30
-rw-r--r--xkbpath.c7
7 files changed, 35 insertions, 68 deletions
diff --git a/compat.c b/compat.c
index 5475a75..479c8d2 100644
--- a/compat.c
+++ b/compat.c
@@ -133,8 +133,7 @@ InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
static void
ClearCompatInfo(CompatInfo * info, XkbDescPtr xkb)
{
- if (info->name != NULL)
- free(info->name);
+ free(info->name);
info->name = NULL;
info->dflt.defs.defined = 0;
info->dflt.defs.merge = MergeAugment;
@@ -425,8 +424,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@@ -880,7 +878,6 @@ CompileCompatMap(XkbFile * file,
ClearCompatInfo(&info, xkb);
return True;
}
- if (info.interps != NULL)
- free(info.interps);
+ free(info.interps);
return False;
}
diff --git a/geometry.c b/geometry.c
index cbacba6..032872a 100644
--- a/geometry.c
+++ b/geometry.c
@@ -291,10 +291,8 @@ FreeProperties(PropertyInfo * pi, GeometryInfo * info)
}
for (tmp = pi; tmp != NULL; tmp = next)
{
- if (tmp->name)
- free(tmp->name);
- if (tmp->value)
- free(tmp->value);
+ free(tmp->name);
+ free(tmp->value);
tmp->name = tmp->value = NULL;
next = (PropertyInfo *) tmp->defs.next;
free(tmp);
@@ -676,8 +674,7 @@ InitGeometryInfo(GeometryInfo * info, unsigned fileID, unsigned merge)
static void
ClearGeometryInfo(GeometryInfo * info)
{
- if (info->name)
- free(info->name);
+ free(info->name);
info->name = NULL;
if (info->props)
FreeProperties(info->props, info);
@@ -750,8 +747,7 @@ AddProperty(GeometryInfo * info, PropertyInfo * new)
ACTION("Ignoring \"%s\", using \"%s\"\n", old->value,
new->value);
}
- if (old->value)
- free(old->value);
+ free(old->value);
old->value = uStringDup(new->value);
return True;
}
@@ -1352,8 +1348,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, XkbDescPtr xkb, GeometryInfo * info,
(*hndlr) (rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
diff --git a/keycodes.c b/keycodes.c
index 9603376..8904774 100644
--- a/keycodes.c
+++ b/keycodes.c
@@ -270,8 +270,7 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
static void
ClearKeyNamesInfo(KeyNamesInfo * info)
{
- if (info->name != NULL)
- free(info->name);
+ free(info->name);
info->name = NULL;
info->computedMax = info->explicitMax = info->explicitMin = -1;
info->computedMin = 256;
@@ -517,8 +516,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, XkbDescPtr xkb, KeyNamesInfo * info)
HandleKeycodesFile(rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
diff --git a/keytypes.c b/keytypes.c
index 8f6d5c7..74f0d26 100644
--- a/keytypes.c
+++ b/keytypes.c
@@ -202,16 +202,12 @@ InitKeyTypesInfo(KeyTypesInfo * info, XkbDescPtr xkb, KeyTypesInfo * from)
static void
FreeKeyTypeInfo(KeyTypeInfo * type)
{
- if (type->entries != NULL)
- {
- free(type->entries);
- type->entries = NULL;
- }
- if (type->lvlNames != NULL)
- {
- free(type->lvlNames);
- type->lvlNames = NULL;
- }
+ free(type->entries);
+ type->entries = NULL;
+
+ free(type->lvlNames);
+ type->lvlNames = NULL;
+
if (type->preserve != NULL)
{
ClearCommonInfo(&type->preserve->defs);
@@ -224,8 +220,7 @@ static void
FreeKeyTypesInfo(KeyTypesInfo * info)
{
info->dpy = NULL;
- if (info->name)
- free(info->name);
+ free(info->name);
info->name = NULL;
if (info->types)
{
@@ -420,8 +415,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, newMerge, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
diff --git a/parseutils.c b/parseutils.c
index 3299245..5c70f81 100644
--- a/parseutils.c
+++ b/parseutils.c
@@ -770,15 +770,11 @@ IncludeCreate(char *str, unsigned merge)
while (first)
{
incl = first->next;
- if (first->file)
- free(first->file);
- if (first->map)
- free(first->map);
- if (first->modifier)
- free(first->modifier);
- if (first->path)
- free(first->path);
- first->file = first->map = first->path = NULL;
+ free(first->file);
+ free(first->map);
+ free(first->modifier);
+ free(first->path);
+ first->file = first->map = first->modifier = first->path = NULL;
free(first);
first = incl;
}
diff --git a/symbols.c b/symbols.c
index 75adbaf..d43d03c 100644
--- a/symbols.c
+++ b/symbols.c
@@ -123,11 +123,9 @@ FreeKeyInfo(KeyInfo * info)
{
info->numLevels[i] = 0;
info->types[i] = None;
- if (info->syms[i] != NULL)
- free(info->syms[i]);
+ free(info->syms[i]);
info->syms[i] = NULL;
- if (info->acts[i] != NULL)
- free(info->acts[i]);
+ free(info->acts[i]);
info->acts[i] = NULL;
}
info->dfltType = None;
@@ -256,8 +254,7 @@ InitSymbolsInfo(SymbolsInfo * info, XkbDescPtr xkb)
static void
FreeSymbolsInfo(SymbolsInfo * info)
{
- if (info->name)
- free(info->name);
+ free(info->name);
info->name = NULL;
if (info->keys)
{
@@ -475,10 +472,8 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
{
if (into->numLevels[i] != 0)
{
- if (into->syms[i])
- free(into->syms[i]);
- if (into->acts[i])
- free(into->acts[i]);
+ free(into->syms[i]);
+ free(into->acts[i]);
}
}
*into = *from;
@@ -787,8 +782,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@@ -1533,11 +1527,9 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
for (int i = 1; i < XkbNumKbdGroups; i++)
{
key->numLevels[i] = 0;
- if (key->syms[i] != NULL)
- free(key->syms[i]);
+ free(key->syms[i]);
key->syms[i] = (KeySym *) NULL;
- if (key->acts[i] != NULL)
- free(key->acts[i]);
+ free(key->acts[i]);
key->acts[i] = (XkbAction *) NULL;
key->types[i] = (Atom) 0;
}
@@ -1923,11 +1915,9 @@ PrepareKeyDef(KeyInfo * key)
for (i = lastGroup; i > 0; i--)
{
key->numLevels[i] = 0;
- if (key->syms[i] != NULL)
- free(key->syms[i]);
+ free(key->syms[i]);
key->syms[i] = (KeySym *) NULL;
- if (key->acts[i] != NULL)
- free(key->acts[i]);
+ free(key->acts[i]);
key->acts[i] = (XkbAction *) NULL;
key->types[i] = (Atom) 0;
}
diff --git a/xkbpath.c b/xkbpath.c
index 1e2b243..695c13e 100644
--- a/xkbpath.c
+++ b/xkbpath.c
@@ -182,11 +182,8 @@ XkbClearIncludePath(void)
{
for (int i = 0; i < nPathEntries; i++)
{
- if (includePath[i] != NULL)
- {
- free(includePath[i]);
- includePath[i] = NULL;
- }
+ free(includePath[i]);
+ includePath[i] = NULL;
}
nPathEntries = 0;
}