From a48c2cf4e5a9136bf23f4d73a5fe141ebf180e1a Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Mon, 19 Oct 2020 19:52:48 +0200 Subject: Bump liberty The bugfixes in the config parser are worth it. I might have slightly overused cstr_set(). --- big-brother.c | 5 ++--- fancontrol-ng.c | 10 +++++----- iexec.c | 4 +--- liberty | 2 +- paswitch.c | 19 ++++++------------- wmstatus.c | 32 +++++++++++++------------------- 6 files changed, 28 insertions(+), 44 deletions(-) diff --git a/big-brother.c b/big-brother.c index 323a4a9..34d584e 100644 --- a/big-brother.c +++ b/big-brother.c @@ -149,7 +149,7 @@ static void app_context_free (struct app_context *self) { str_map_free (&self->config); - free (self->current_title); + cstr_set (&self->current_title, NULL); poller_fd_reset (&self->x_event); XCloseDisplay (self->dpy); poller_free (&self->poller); @@ -207,8 +207,7 @@ update_window_title (struct app_context *ctx, char *new_title) { bool changed = !ctx->current_title != !new_title || (new_title && strcmp (ctx->current_title, new_title)); - free (ctx->current_title); - ctx->current_title = new_title; + cstr_set (&ctx->current_title, new_title); return changed; } diff --git a/fancontrol-ng.c b/fancontrol-ng.c index ed37689..ec06dfb 100644 --- a/fancontrol-ng.c +++ b/fancontrol-ng.c @@ -225,12 +225,12 @@ paths_new (const char *device_path, const char *path, struct config_item *pwm) static void paths_destroy (struct paths *self) { - free (self->temp); + cstr_set (&self->temp, NULL); - free (self->pwm); - free (self->pwm_enable); - free (self->pwm_min); - free (self->pwm_max); + cstr_set (&self->pwm, NULL); + cstr_set (&self->pwm_enable, NULL); + cstr_set (&self->pwm_min, NULL); + cstr_set (&self->pwm_max, NULL); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iexec.c b/iexec.c index fd211e1..cd9dc97 100644 --- a/iexec.c +++ b/iexec.c @@ -105,9 +105,7 @@ main (int argc, char *argv[]) "PROGRAM [ARG...]", "Run a program and restart on file change."); // We have to turn that off as it causes more trouble than what it's worth - char *nonpermuting = xstrdup_printf ("+%s", oh.opt_string); - free (oh.opt_string); - oh.opt_string = nonpermuting; + cstr_set (&oh.opt_string, xstrdup_printf ("+%s", oh.opt_string)); int c; while ((c = opt_handler_get (&oh)) != -1) diff --git a/liberty b/liberty index 1a76b20..69101eb 160000 --- a/liberty +++ b/liberty @@ -1 +1 @@ -Subproject commit 1a76b2032e6d18d9f95d9d0bb98edc26023c8618 +Subproject commit 69101eb1554ad2fca6de30cdbaccac076210d7e3 diff --git a/paswitch.c b/paswitch.c index ec83d07..b43fc00 100644 --- a/paswitch.c +++ b/paswitch.c @@ -45,13 +45,6 @@ enum { PIPE_READ, PIPE_WRITE }; -static void -cstr_set (char **s, char *new) -{ - free (*s); - *s = new; -} - static void log_message_custom (void *user_data, const char *quote, const char *fmt, va_list ap) @@ -79,8 +72,8 @@ struct port static void port_free (struct port *self) { - free (self->name); - free (self->description); + cstr_set (&self->name, NULL); + cstr_set (&self->description, NULL); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -109,14 +102,14 @@ sink_new (void) static void sink_destroy (struct sink *self) { - free (self->name); - free (self->description); + cstr_set (&self->name, NULL); + cstr_set (&self->description, NULL); for (size_t i = 0; i < self->ports_len; i++) port_free (self->ports + i); free (self->ports); - free (self->port_active); + cstr_set (&self->port_active, NULL); free (self); } @@ -185,7 +178,7 @@ app_context_free (struct app_context *self) if (self->context) pa_context_unref (self->context); - free (self->default_sink); + cstr_set (&self->default_sink, NULL); LIST_FOR_EACH (struct sink, iter, self->sinks) sink_destroy (iter); LIST_FOR_EACH (struct sink_input, iter, self->inputs) diff --git a/wmstatus.c b/wmstatus.c index baa1ed6..20c7689 100644 --- a/wmstatus.c +++ b/wmstatus.c @@ -951,7 +951,7 @@ app_context_free (struct app_context *self) if (self->backend) self->backend->destroy (self->backend); poller_fd_reset (&self->x_event); - free (self->layout); + cstr_set (&self->layout, NULL); if (self->context) pa_context_unref (self->context); if (self->dpy) XCloseDisplay (self->dpy); @@ -966,19 +966,20 @@ app_context_free (struct app_context *self) } str_free (&self->command_buffer); - free (self->insomnia_info); + cstr_set (&self->insomnia_info, NULL); if (self->insomnia_fd != -1) xclose (self->insomnia_fd); mpd_client_free (&self->mpd_client); - free (self->mpd_song); - free (self->mpd_status); + cstr_set (&self->mpd_song, NULL); + cstr_set (&self->mpd_status, NULL); nut_client_free (&self->nut_client); str_map_free (&self->nut_ups_info); + cstr_set (&self->nut_status, NULL); strv_free (&self->sink_ports); - free (self->sink_port_active); + cstr_set (&self->sink_port_active, NULL); poller_pa_destroy (self->api); poller_free (&self->poller); @@ -1437,8 +1438,7 @@ mpd_on_info_response (const struct mpd_response *response, struct str_map map; mpd_vector_to_map (data, &map); - free (ctx->mpd_status); - ctx->mpd_status = NULL; + cstr_set (&ctx->mpd_status, NULL); struct str s = str_make (); @@ -1464,8 +1464,7 @@ mpd_on_info_response (const struct mpd_response *response, if ((value = str_map_find (&map, "album"))) str_append_printf (&s, " from \001%s\001", value); - free (ctx->mpd_song); - ctx->mpd_song = str_steal (&s); + cstr_set (&ctx->mpd_song, str_steal (&s)); refresh_status (ctx); str_map_free (&map); @@ -1708,8 +1707,7 @@ nut_on_logout_response (const struct nut_response *response, void *user_data) while ((dict = str_map_iter_next (&iter))) nut_process_ups (ctx, &ups_list, iter.link->key, dict); - free (ctx->nut_status); - ctx->nut_status = NULL; + cstr_set (&ctx->nut_status, NULL); if (ups_list.len) { @@ -1800,8 +1798,7 @@ nut_on_connected (void *user_data) static void nut_indicate_failure (struct app_context *ctx) { - free (ctx->nut_status); - ctx->nut_status = xstrdup ("NUT failure"); + cstr_set (&ctx->nut_status, xstrdup ("NUT failure")); refresh_status (ctx); } @@ -1870,8 +1867,7 @@ on_sink_info (pa_context *context, const pa_sink_info *info, int eol, ctx->sink_muted = !!info->mute; strv_reset (&ctx->sink_ports); - free (ctx->sink_port_active); - ctx->sink_port_active = NULL; + cstr_set (&ctx->sink_port_active, NULL); if (info->ports) for (struct pa_sink_port_info **iter = info->ports; *iter; iter++) @@ -2167,8 +2163,7 @@ static void on_insomnia (struct app_context *ctx, int arg) { (void) arg; - free (ctx->insomnia_info); - ctx->insomnia_info = NULL; + cstr_set (&ctx->insomnia_info, NULL); // Get rid of the lock if we hold one, establish it otherwise if (ctx->insomnia_fd != -1) @@ -2282,8 +2277,7 @@ on_xkb_event (struct app_context *ctx, XkbEvent *ev) XkbDescPtr desc = XkbAllocKeyboard (); XkbGetNames (ctx->dpy, XkbGroupNamesMask, desc); - free (ctx->layout); - ctx->layout = NULL; + cstr_set (&ctx->layout, NULL); if (group != 0) { -- cgit v1.2.3-70-g09d2