From b47d419c25ecc735615a1088060c1ec8bef1e41f Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sat, 12 Oct 2013 12:15:49 -0400 Subject: Modernization Fixes minor leak in error path in device.c. --- src/readahead/readahead-collect.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/readahead') diff --git a/src/readahead/readahead-collect.c b/src/readahead/readahead-collect.c index 6b748664c3..58b77bdcf7 100644 --- a/src/readahead/readahead-collect.c +++ b/src/readahead/readahead-collect.c @@ -415,7 +415,8 @@ static int collect(const char *root) { } } - if ((n = read(fanotify_fd, &data, sizeof(data))) < 0) { + n = read(fanotify_fd, &data, sizeof(data)); + if (n < 0) { if (errno == EINTR || errno == EAGAIN) continue; @@ -436,7 +437,7 @@ static int collect(const char *root) { } for (m = &data.metadata; FAN_EVENT_OK(m, n); m = FAN_EVENT_NEXT(m, n)) { - char fn[PATH_MAX]; + char fn[sizeof("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; int k; if (m->fd < 0) @@ -450,9 +451,8 @@ static int collect(const char *root) { goto next_iteration; snprintf(fn, sizeof(fn), "/proc/self/fd/%i", m->fd); - char_array_0(fn); - - if ((k = readlink_malloc(fn, &p)) >= 0) { + k = readlink_malloc(fn, &p); + if (k >= 0) { if (startswith(p, "/tmp") || endswith(p, " (deleted)") || hashmap_get(files, p)) -- cgit v1.2.3-54-g00ecf