Skip to content

Commit

Permalink
smbios: use g_free directly on NULL pointers
Browse files Browse the repository at this point in the history
No need to wrap it with an if.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Benoit Canet <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
bonzini authored and Michael Tokarev committed Jun 10, 2014
1 parent 6998b6c commit a10678b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions hw/i386/smbios.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,11 +745,6 @@ void smbios_set_cpuid(uint32_t version, uint32_t features)
field = value; \
}

#define G_FREE_UNLESS_NULL(ptr) \
if (ptr != NULL) { \
g_free(ptr); \
}

void smbios_set_defaults(const char *manufacturer, const char *product,
const char *version, bool legacy_mode)
{
Expand All @@ -758,7 +753,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product,

/* drop unwanted version of command-line file blob(s) */
if (smbios_legacy) {
G_FREE_UNLESS_NULL(smbios_tables);
g_free(smbios_tables);
/* in legacy mode, also complain if fields were given for types > 1 */
if (find_next_bit(have_fields_bitmap,
SMBIOS_MAX_TYPE+1, 2) < SMBIOS_MAX_TYPE+1) {
Expand All @@ -767,7 +762,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
exit(1);
}
} else {
G_FREE_UNLESS_NULL(smbios_entries);
g_free(smbios_entries);
}

SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
Expand Down

0 comments on commit a10678b

Please sign in to comment.