From 0a4d8cbdcd7b25313fb29ccdb498044af95f7de6 Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Sun, 6 Jun 2010 15:28:30 +0700 Subject: Remove more superfluous if(p) checks around free(p) This patch has been generated by the following Coccinelle semantic patch: @@ expression E; @@ -if(E) { free(E); } +free(E); Signed-off-by: Mikhail Gusarov Reviewed-by: Julien Cristau Reviewed-by: Fernando Carrijo Reviewed-by: Matt Turner --- config/hal.c | 48 ++++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'config/hal.c') diff --git a/config/hal.c b/config/hal.c index 6a2232364..5938d4e24 100644 --- a/config/hal.c +++ b/config/hal.c @@ -251,28 +251,23 @@ device_added(LibHalContext *hal_ctx, const char *udi) { if (!strcasecmp(&tmp[3], "layout")) { - if (xkb_opts.layout) - free(xkb_opts.layout); + free(xkb_opts.layout); xkb_opts.layout = strdup(tmp_val); } else if (!strcasecmp(&tmp[3], "model")) { - if (xkb_opts.model) - free(xkb_opts.model); + free(xkb_opts.model); xkb_opts.model = strdup(tmp_val); } else if (!strcasecmp(&tmp[3], "rules")) { - if (xkb_opts.rules) - free(xkb_opts.rules); + free(xkb_opts.rules); xkb_opts.rules = strdup(tmp_val); } else if (!strcasecmp(&tmp[3], "variant")) { - if (xkb_opts.variant) - free(xkb_opts.variant); + free(xkb_opts.variant); xkb_opts.variant = strdup(tmp_val); } else if (!strcasecmp(&tmp[3], "options")) { - if (xkb_opts.options) - free(xkb_opts.options); + free(xkb_opts.options); xkb_opts.options = strdup(tmp_val); } } else @@ -289,8 +284,7 @@ device_added(LibHalContext *hal_ctx, const char *udi) (!strcasecmp(&tmp[3], "options")) && (tmp_val = get_prop_string_array(hal_ctx, udi, psi_key))) { - if (xkb_opts.options) - free(xkb_opts.options); + free(xkb_opts.options); xkb_opts.options = strdup(tmp_val); } } @@ -366,22 +360,17 @@ device_added(LibHalContext *hal_ctx, const char *udi) } for (; dev; dev = dev->next){ - if (dev->config_info) - free(dev->config_info); + free(dev->config_info); dev->config_info = xstrdup(config_info); } unwind: if (set) libhal_free_property_set(set); - if (path) - free(path); - if (driver) - free(driver); - if (name) - free(name); - if (config_info) - free(config_info); + free(path); + free(driver); + free(name); + free(config_info); while (!dev && (tmpo = options)) { options = tmpo->next; free(tmpo->key); @@ -401,16 +390,11 @@ unwind: free(attrs.tags); } - if (xkb_opts.layout) - free(xkb_opts.layout); - if (xkb_opts.rules) - free(xkb_opts.rules); - if (xkb_opts.model) - free(xkb_opts.model); - if (xkb_opts.variant) - free(xkb_opts.variant); - if (xkb_opts.options) - free(xkb_opts.options); + free(xkb_opts.layout); + free(xkb_opts.rules); + free(xkb_opts.model); + free(xkb_opts.variant); + free(xkb_opts.options); dbus_error_free(&error); -- cgit v1.2.3