Skip to content

Commit

Permalink
kconfig: remove redundant NULL pointer check before free()
Browse files Browse the repository at this point in the history
Passing NULL to free() is allowed and is a no-op.

Remove redundant NULL pointer checks.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
Masahiro Yamada committed Dec 28, 2023
1 parent 9ad86d7 commit 407868d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ int conf_read_simple(const char *name, int def)
case S_INT:
case S_HEX:
case S_STRING:
if (sym->def[def].val)
free(sym->def[def].val);
free(sym->def[def].val);
/* fall through */
default:
sym->def[def].val = NULL;
Expand Down
3 changes: 1 addition & 2 deletions scripts/kconfig/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ struct gstr str_new(void)
/* Free storage for growable string */
void str_free(struct gstr *gs)
{
if (gs->s)
free(gs->s);
free(gs->s);
gs->s = NULL;
gs->len = 0;
}
Expand Down

0 comments on commit 407868d

Please sign in to comment.