Skip to contentSkip to conversation

Fix build with glibc-2.42

PATCH In review Steve Dickson 1 participant 2 messages Jun 27, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix build with glibc-2.42

From: Yaakov Selkowitz <[email protected]>

exportfs.c: In function ‘release_lockfile’:
exportfs.c:83:17: error: ignoring return value of ‘lockf’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]

   83 |                 lockf(_lockfd, F_ULOCK, 0);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
exportfs.c: In function ‘grab_lockfile’:
exportfs.c:77:17: error: ignoring return value of ‘lockf’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
   77 |                 lockf(_lockfd, F_LOCK, 0);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~

lockf is now marked with attribute warn_unused_result:

https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f3c82fc1b41261f582f5f9fa12f74af9bcbc88f9

---
 utils/exportfs/exportfs.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
utils/exportfs/exportfs.c +8 -2
index b03a047b..748c38e3 100644
@@ -74,13 +74,19 @@ grab_lockfile(void)
 {
 	_lockfd = open(lockfile, O_CREAT|O_RDWR, 0666);
 	if (_lockfd != -1)
-		lockf(_lockfd, F_LOCK, 0);
+		if (lockf(_lockfd, F_LOCK, 0) != 0) {
+			xlog_warn("%s: lockf() failed: errno %d (%s)",
+			__func__, errno, strerror(errno));
+		}
 }
 static void
 release_lockfile(void)
 {
 	if (_lockfd != -1) {
-		lockf(_lockfd, F_ULOCK, 0);
+		if (lockf(_lockfd, F_ULOCK, 0) != 0) {
+			xlog_warn("%s: lockf() failed: errno %d (%s)",
+			__func__, errno, strerror(errno));
+		}
 		close(_lockfd);
 		_lockfd = -1;
 	}
Signature · 1 line
2.50.0
#1 lore raw
Quoted 11 lines · Steve Dickson

From: Yaakov Selkowitz <[email protected]>

exportfs.c: In function ‘release_lockfile’:
exportfs.c:83:17: error: ignoring return value of ‘lockf’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]

    83 |                 lockf(_lockfd, F_ULOCK, 0);
       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
exportfs.c: In function ‘grab_lockfile’:
exportfs.c:77:17: error: ignoring return value of ‘lockf’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
    77 |                 lockf(_lockfd, F_LOCK, 0);
       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 5 lines

lockf is now marked with attribute warn_unused_result:

https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f3c82fc1b41261f582f5f9fa12f74af9bcbc88f9

Committed... (tag: nfs-utils-2-8-4-rc3)

steved.

Quoted 30 lines
---
  utils/exportfs/exportfs.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
utils/exportfs/exportfs.c +8 -2
index b03a047b..748c38e3 100644
@@ -74,13 +74,19 @@ grab_lockfile(void)
  {
  	_lockfd = open(lockfile, O_CREAT|O_RDWR, 0666);
  	if (_lockfd != -1)
-		lockf(_lockfd, F_LOCK, 0);
+		if (lockf(_lockfd, F_LOCK, 0) != 0) {
+			xlog_warn("%s: lockf() failed: errno %d (%s)",
+			__func__, errno, strerror(errno));
+		}
  }
  static void
  release_lockfile(void)
  {
  	if (_lockfd != -1) {
-		lockf(_lockfd, F_ULOCK, 0);
+		if (lockf(_lockfd, F_ULOCK, 0) != 0) {
+			xlog_warn("%s: lockf() failed: errno %d (%s)",
+			__func__, errno, strerror(errno));
+		}
  		close(_lockfd);
  		_lockfd = -1;
  	}