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.smir...@gmail.com>
---
 common/filetype.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/filetype.c b/common/filetype.c
index f8b6bc895..fb029a773 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;
 }
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to