[systemd-devel] [PATCH] dbus: use _cleanup_free_ instead of freeing ourself

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Wed Aug 7 21:28:28 PDT 2013


On Thu, Jul 25, 2013 at 05:36:01PM +0200, Ronny Chevalier wrote:
> ---
>  src/core/dbus-execute.c |  3 +--
>  src/core/dbus-job.c     | 11 ++---------
>  src/core/dbus-manager.c | 14 +++-----------
>  src/core/unit.c         | 48 ++++++++++++++++++++++--------------------------
>  4 files changed, 28 insertions(+), 48 deletions(-)
Applied...

> @@ -1225,12 +1224,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
>                          p = bus_path_escape(k);
>                          if (!p) {
>                                  fclose(f);
> -                                free(introspection);
>                                  goto oom;
>                          }
... but you could think about also applying _cleanup_fclose_ here.
This would completely kill the cleanup in error handling blocks,
making things simpler.

>  int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data) {
> -        _cleanup_free_ char *p = NULL, *q = NULL;
> +        _cleanup_free_ char *p = NULL;
> +        _cleanup_free_ char *q = NULL;
... and I removed those parts which split variable declarations into
separate lines. They were fine as they were.

Zbyszek


More information about the systemd-devel mailing list