From c6c1ec81e0277fded6c6a97dcf69943b44b56052 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 3 Aug 2021 14:16:33 +0800 Subject: [PATCH] Fix variable 'catd' is used uninitialized whenever 'if' condition is false Signed-off-by: Xiang Xiao --- libs/libc/locale/lib_catalog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/libc/locale/lib_catalog.c b/libs/libc/locale/lib_catalog.c index 32f8614698..0dbb1a099e 100644 --- a/libs/libc/locale/lib_catalog.c +++ b/libs/libc/locale/lib_catalog.c @@ -79,14 +79,14 @@ struct catmsg_s static nl_catd catmap(FAR const char *path) { FAR const struct cathdr_s *hdr; + nl_catd catd = MAP_FAILED; struct stat st; - nl_catd catd; int fd; fd = open(path, O_RDONLY | O_CLOEXEC); if (fd < 0) { - return MAP_FAILED; + return catd; } if (fstat(fd, &st) >= 0)