kconfig: remove redundant NULL pointer check before free()

Passing NULL to free() is allowed and is a no-op.

Remove redundant NULL pointer checks.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
Masahiro Yamada 2023-12-03 19:25:28 +09:00
parent 9ad86d747c
commit 407868deb2
2 changed files with 2 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}