summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-07-19 20:46:17 +0200
committerLennart Poettering <lennart@poettering.net>2016-07-21 11:37:58 +0200
commitdb6d9faeb0179b15cf29e87bd20d29d6210142ef (patch)
tree81d0e366febd9471f8ebf5ea175014f56ff17233 /src
parent5fa6c13c7bd6df488c0585608688a5feb8a03d5d (diff)
bootctl: clean up get_file_version()
Make sure that we always initialize the return parameter on success, and that all errors result in an error message, not just some.
Diffstat (limited to 'src')
-rw-r--r--src/boot/bootctl.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 9a24ecd6b2..ff14cff166 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -275,14 +275,16 @@ static int get_file_version(int fd, char **v) {
assert(v);
if (fstat(fd, &st) < 0)
- return -errno;
+ return log_error_errno(errno, "Failed to stat EFI binary: %m");
- if (st.st_size < 27)
+ if (st.st_size < 27) {
+ *v = NULL;
return 0;
+ }
buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (buf == MAP_FAILED)
- return -errno;
+ return log_error_errno(errno, "Failed to memory map EFI binary: %m");
s = memmem(buf, st.st_size - 8, "#### LoaderInfo: ", 17);
if (!s)
@@ -304,7 +306,7 @@ static int get_file_version(int fd, char **v) {
r = 1;
finish:
- munmap(buf, st.st_size);
+ (void) munmap(buf, st.st_size);
*v = x;
return r;
}