From 37d18559071a4228c8148d5b1de869ff78bb3118 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Wed, 10 May 2023 16:32:30 +0200 Subject: [PATCH] lx_fs: fix build errors with GCC 12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /data/genode/repos/os/src/server/lx_fs/directory.h: In member function ‘virtual Genode::size_t Lx_fs::Directory::read(char*, Genode::size_t, File_system::seek_off_t)’: /data/genode/repos/os/src/server/lx_fs/directory.h:224:53: error: ‘dent’ may be used uninitialized [-Werror=maybe-uninitialized] 224 | .type = type(dent->d_type), | ~~~~~~^~~~~~ /data/genode/repos/os/src/server/lx_fs/directory.h:197:40: note: ‘dent’ was declared here 197 | struct dirent *dent; | ^~~~ Issue genodelabs/genode#4827 --- repos/os/src/server/lx_fs/directory.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repos/os/src/server/lx_fs/directory.h b/repos/os/src/server/lx_fs/directory.h index acfed71e5b..d6f793afbe 100644 --- a/repos/os/src/server/lx_fs/directory.h +++ b/repos/os/src/server/lx_fs/directory.h @@ -193,12 +193,12 @@ class Lx_fs::Directory : public Node seek_off_t index = seek_offset / sizeof(Directory_entry); - /* seek to index and read entry */ - struct dirent *dent; + /* seek to index */ rewinddir(_fd); - for (unsigned i = 0; i <= index; ++i) { - dent = readdir(_fd); - } + for (unsigned i = 0; i < index; ++i) + readdir(_fd); + + struct dirent *dent = readdir(_fd); if (!dent) return 0;