summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-11-28 13:26:15 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-11-28 21:34:50 +0100
commitae34a10bac21a9d2b004755163a039a3a6e73c7d (patch)
treee2e4df41995a788143bf87f6937f0137e08a8157 /src/udev
parent3176084ff230afeb1d23d5647dd64ba4b7b982cc (diff)
downloadsystemd-ae34a10bac21a9d2b004755163a039a3a6e73c7d.tar.gz
systemd-ae34a10bac21a9d2b004755163a039a3a6e73c7d.tar.bz2
systemd-ae34a10bac21a9d2b004755163a039a3a6e73c7d.zip
udev/collect: use _cleanup_ in one more place
This doesn't make the code pretty, but it at least makes it a tiny bit shorter.
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/collect/collect.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index 975842be4f..14e97e6f48 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -135,7 +135,8 @@ static int prepare(char *dir, char *filename)
static int checkout(int fd)
{
int len;
- char *buf, *ptr, *word = NULL;
+ _cleanup_free_ char *buf = NULL;
+ char *ptr, *word = NULL;
struct _mate *him;
restart:
@@ -155,7 +156,6 @@ static int checkout(int fd)
bufsize = bufsize << 1;
if (debug)
fprintf(stderr, "ID overflow, restarting with size %zu\n", bufsize);
- free(buf);
lseek(fd, 0, SEEK_SET);
goto restart;
}
@@ -168,13 +168,10 @@ static int checkout(int fd)
if (debug)
fprintf(stderr, "Found word %s\n", word);
him = malloc(sizeof (struct _mate));
- if (!him) {
- free(buf);
+ if (!him)
return log_oom();
- }
him->name = strdup(word);
if (!him->name) {
- free(buf);
free(him);
return log_oom();
}
@@ -191,7 +188,6 @@ static int checkout(int fd)
ptr -= len;
}
- free(buf);
return 0;
}