summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-06 23:49:11 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 07:55:45 +0100
commit7c293700db4d1b14ba55bc221af9afc0ed233f01 (patch)
treef67517af80584e344813215935a155878d80af8a
parent05374a6eded63894263a27886ef19056362967be (diff)
downloadbarebox-7c293700db4d1b14ba55bc221af9afc0ed233f01.tar.gz
barebox-7c293700db4d1b14ba55bc221af9afc0ed233f01.tar.xz
common: Always return enum filetype in file_name_detect_type_offset()
None of the callers of file_name_detect_type_offset() are prepared to deal with negative error code. Change the code to return filetype_unknown if open_and_lseek() fails. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/filetype.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/filetype.c b/common/filetype.c
index f8b6bc8954..fb029a7739 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -383,7 +383,7 @@ enum filetype file_name_detect_type_offset(const char *filename, loff_t pos)
fd = open_and_lseek(filename, O_RDONLY, pos);
if (fd < 0)
- return fd;
+ goto out;
buf = xzalloc(FILE_TYPE_SAFE_BUFSIZE);
@@ -396,7 +396,7 @@ enum filetype file_name_detect_type_offset(const char *filename, loff_t pos)
err_out:
close(fd);
free(buf);
-
+out:
return type;
}