fix built on new gcc (bison based code and libblkid API)

This commit is contained in:
Karel Zak 2026-01-12 11:55:59 +01:00
commit 06dbf9bb28
3 changed files with 112 additions and 0 deletions

View file

@ -0,0 +1,63 @@
From b3e1a72d0272c8dc26db8c11c61cd4fed6a6b95f Mon Sep 17 00:00:00 2001
From: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Date: Tue, 6 Jan 2026 10:43:45 -0500
Subject: build-sys: (gcc) ignore -Wunused-but-set-variable for bison
[kzak@redhat.com: - merge two Christian's patches to make it more portable]
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit db9047892a45c06bceb5768e7bb8c887289b9859)
(cherry picked from commit 718e4a76dd1262ce97f83dbc0c0fe9f97564ecbb)
---
libsmartcols/src/filter-parser.y | 11 +++++++----
sys-utils/hwclock-parse-date.y | 11 +++++++----
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/libsmartcols/src/filter-parser.y b/libsmartcols/src/filter-parser.y
index a7d41408e..23b05df33 100644
--- a/libsmartcols/src/filter-parser.y
+++ b/libsmartcols/src/filter-parser.y
@@ -1,9 +1,12 @@
%{
-#ifdef __clang__
-/* clang detects yynerrs as unused.
- * Will be fixed in future versions of bison.
+/*
+ * Compilers detect yynerrs as unused. Let's hope it will be fixed in future
+ * versions of Bison.
*/
-#pragma clang diagnostic ignored "-Wunused-but-set-variable"
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#elif defined(__clang__)
+# pragma clang diagnostic ignored "-Wunused-but-set-variable"
#endif
#include <stdio.h>
diff --git a/sys-utils/hwclock-parse-date.y b/sys-utils/hwclock-parse-date.y
index 0d996cc87..7d6c38268 100644
--- a/sys-utils/hwclock-parse-date.y
+++ b/sys-utils/hwclock-parse-date.y
@@ -34,11 +34,14 @@
* TZ strings in dates.
*/
-#ifdef __clang__
-/* clang 15 detects yynerrs as unused.
- * Will be fixed in future versions of bison.
+/*
+ * Compilers detect yynerrs as unused. Let's hope it will be fixed in future
+ * versions of Bison.
*/
-#pragma clang diagnostic ignored "-Wunused-but-set-variable"
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#elif defined(__clang__)
+# pragma clang diagnostic ignored "-Wunused-but-set-variable"
#endif
/**
--
2.52.0

View file

@ -0,0 +1,44 @@
From b994886e18307ef3002a63679fba4a6177f476cf Mon Sep 17 00:00:00 2001
From: Daan De Meyer <daan.j.demeyer@gmail.com>
Date: Wed, 26 Nov 2025 15:08:25 +0100
Subject: blkid: Drop const from blkid_partitions_get_name()
const for idx is useless as the value is copied anyway, so drop the
const. AFAIK this doesn't change ABI.
(cherry picked from commit b243de928aab8565e264f4af1d776cc860689f64)
(cherry picked from commit 479133958af89a2afda442e158107b465301dfbb)
---
libblkid/src/blkid.h.in | 2 +-
libblkid/src/partitions/partitions.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
index 91fc3b0be..031650dbc 100644
--- a/libblkid/src/blkid.h.in
+++ b/libblkid/src/blkid.h.in
@@ -340,7 +340,7 @@ extern uint64_t blkid_topology_get_diskseq(blkid_topology tp)
* partitions probing
*/
extern int blkid_known_pttype(const char *pttype);
-extern int blkid_partitions_get_name(const size_t idx, const char **name);
+extern int blkid_partitions_get_name(size_t idx, const char **name);
extern int blkid_probe_enable_partitions(blkid_probe pr, int enable)
__ul_attribute__((nonnull));
diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c
index 9df813c92..e838b3db1 100644
--- a/libblkid/src/partitions/partitions.c
+++ b/libblkid/src/partitions/partitions.c
@@ -907,7 +907,7 @@ int blkid_known_pttype(const char *pttype)
*
* Returns: -1 if @idx is out of range, or 0 on success.
*/
-int blkid_partitions_get_name(const size_t idx, const char **name)
+int blkid_partitions_get_name(size_t idx, const char **name)
{
if (idx < ARRAY_SIZE(idinfos)) {
*name = idinfos[idx]->name;
--
2.52.0

View file

@ -109,6 +109,11 @@ Patch1: 0001-login-add-run-motd.d-to-the-hardcoded-MOTD_FILE.patch
### Temporary dracut workaround
Patch2: 0002-libmount-disable-EROFS-backing-file-support.patch
# Upstream backports
Patch3: 0003-build-sys-gcc-ignore-Wunused-but-set-variable-for-bi.patch
Patch4: 0004-blkid-Drop-const-from-blkid_partitions_get_name.patch
%description
The util-linux package contains a large variety of low-level system
utilities that are necessary for a Linux system to function. Among