According to valgrind, fgetflags can assign an uninitialized value (f) to *flags. It happens when ioctl fails. For example, this happens for me with /dev/mqueue on Linux.
This patch should fix it. Alternatively, not setting *flags at all when ioctl fails would be another option. That would be better because I expect *flags not to be modified if there's an error. I think most people would expect that.
fgetflags.c-uninitialized.patch
--- fgetflags.c.orig 2026-04-16 11:08:50.000000000 +1000
+++ fgetflags.c 2026-04-16 11:09:15.000000000 +1000
@@ -80,7 +80,7 @@
return (save_errno);
#elif HAVE_EXT2_IOCTLS
struct stat buf;
- int fd, r, f, save_errno = 0;
+ int fd, r, f = 0, save_errno = 0;
if (!stat(name, &buf) &&
!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
or (better):
fgetflags.c-uninitialized.alternate.patch
--- fgetflags.c.orig 2026-04-16 11:08:50.000000000 +1000
+++ fgetflags.c 2026-04-16 11:17:19.000000000 +1000
@@ -105,7 +105,8 @@
errno = EOPNOTSUPP;
save_errno = errno;
}
- *flags = f;
+ else
+ *flags = f;
close(fd);
if (save_errno)
errno = save_errno;
According to valgrind, fgetflags can assign an uninitialized value (
f) to*flags. It happens when ioctl fails. For example, this happens for me with/dev/mqueueon Linux.This patch should fix it. Alternatively, not setting
*flagsat all when ioctl fails would be another option. That would be better because I expect*flagsnot to be modified if there's an error. I think most people would expect that.fgetflags.c-uninitialized.patch
or (better):
fgetflags.c-uninitialized.alternate.patch