[PATCH] io: Mark lockf() __wur [BZ #32800]

H.J. Lu hjl.tools@gmail.com
Sun Jun 15 02:30:37 GMT 2025


On Sat, Jun 14, 2025 at 5:59 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Radko Krkoš:
>
> > In commit 0476597b28 flock() was marked __wur in posix/unistd.h, but not
> > in io/fcntl.h, the declarations must match.
>
> I'm going to accept this as a non-legally significant contribution under
> the FSF guidelines, so copyright assignment is not needed.
>
> > diff --git a/io/fcntl.h b/io/fcntl.h
> > index 59dc7d4c51..132d83a371 100644
> > --- a/io/fcntl.h
> > +++ b/io/fcntl.h
> > @@ -281,16 +281,17 @@ extern int creat64 (const char *__file, mode_t
> > __mode) __nonnull ((1));
> >   # define F_TEST  3  /* Test a region for other processes locks.  */
> >
> >   # ifndef __USE_FILE_OFFSET64
> > -extern int lockf (int __fd, int __cmd, off_t __len);
> > +extern int lockf (int __fd, int __cmd, off_t __len) __wur;
> >   # else
> >   #  ifdef __REDIRECT
> > -extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len),
> > lockf64);
> > +extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len),
> > +                       lockf64) __wur;
> >   #  else
> >   #   define lockf lockf64
> >   #  endif
> >   # endif
> >   # ifdef __USE_LARGEFILE64
> > -extern int lockf64 (int __fd, int __cmd, off64_t __len);
> > +extern int lockf64 (int __fd, int __cmd, off64_t __len) __wur;
> >   # endif
> >   #endif
>
> I checked that this covers all the remaining cases.  Tested on
> powerpc64le-linux-gnu.
>
> Reviewed-by: Florian Weimer <fweimer@redhat.com>
>
> Thanks,
> Florian
>

This caused:

https://sourceware.org/bugzilla/show_bug.cgi?id=33089

when GCC 14.2.1 is used to build glibc on x86-64:

programs/locarchive.c: In function ‘open_archive’:
programs/locarchive.c:641:18: error: ignoring return value of
‘lockf64’ declared with attribute ‘warn_unused_result’
[-Werror=unused-result]
  641 |           (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead));
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
programs/locarchive.c:653:14: error: ignoring return value of
‘lockf64’ declared with attribute ‘warn_unused_result’
[-Werror=unused-result]
  653 |       (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead));
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
programs/locarchive.c:660:14: error: ignoring return value of
‘lockf64’ declared with attribute ‘warn_unused_result’
[-Werror=unused-result]
  660 |       (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead));
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
programs/locarchive.c:679:14: error: ignoring return value of
‘lockf64’ declared with attribute ‘warn_unused_result’
[-Werror=unused-result]
  679 |       (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead));
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- 
H.J.


More information about the Libc-alpha mailing list