diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-10 14:23:11 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-11 15:36:06 -0800 |
commit | 5655379ce89ab55f25a536972aaa310480de9432 (patch) | |
tree | aa9cffb76485caf32da96d8d689f5a0ce6ab6c11 | |
parent | 2ac6a7f029d8855fbb4e8024aab0511727ac3a67 (diff) |
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.c | 9 | ||||
-rw-r--r-- | geometry.c | 15 | ||||
-rw-r--r-- | keycodes.c | 6 | ||||
-rw-r--r-- | keytypes.c | 22 | ||||
-rw-r--r-- | parseutils.c | 14 | ||||
-rw-r--r-- | symbols.c | 30 | ||||
-rw-r--r-- | xkbpath.c | 7 |
7 files changed, 35 insertions, 68 deletions
@@ -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; } @@ -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; } @@ -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; } @@ -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; } @@ -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; } @@ -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; } |