From: Lennart Poettering Date: Mon, 4 Jun 2018 16:03:02 +0000 (+0200) Subject: core: modernize device_set_sysfs() a bit X-Git-Tag: v239~123^2~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ccd419f0e7c267c82b89287d967509615ef929f4;p=thirdparty%2Fsystemd.git core: modernize device_set_sysfs() a bit --- diff --git a/src/core/device.c b/src/core/device.c index b3f8eb4e023..725aa9d3bf4 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -55,8 +55,8 @@ static void device_unset_sysfs(Device *d) { } static int device_set_sysfs(Device *d, const char *sysfs) { + _cleanup_free_ char *copy = NULL; Device *first; - char *copy; int r; assert(d); @@ -80,12 +80,10 @@ static int device_set_sysfs(Device *d, const char *sysfs) { r = hashmap_replace(UNIT(d)->manager->devices_by_sysfs, copy, first); if (r < 0) { LIST_REMOVE(same_sysfs, first, d); - free(copy); return r; } - d->sysfs = copy; - + d->sysfs = TAKE_PTR(copy); return 0; }