public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/27476] New: getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull
@ 2021-02-26 18:01 slyfox at inbox dot ru
  2021-02-26 18:47 ` [Bug libc/27476] " sam at gentoo dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: slyfox at inbox dot ru @ 2021-02-26 18:01 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 27476
           Summary: getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull
           Product: glibc
           Version: 2.33
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: slyfox at inbox dot ru
                CC: adhemerval.zanella at linaro dot org, drepper.fsp at gmail dot com,
                    fweimer at redhat dot com
  Target Milestone: ---

Extracted from https://github.com/libarchive/libarchive/issues/1498. Small
example:

$ cat a.c
#include <limits.h> /* PATH_MAX */
#include <unistd.h> /* getcwd() */

// from https://github.com/libarchive/libarchive/issues/1498
char * bug(void) {
    return getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
}

$ gcc-10.2.0 -O2 -c a.c -O2 -Wall -Werror=nonnull -D_FORTIFY_SOURCE=0
<command-line>: warning: "_FORTIFY_SOURCE" redefined
<built-in>: note: this is the location of the previous definition
a.c: In function 'bug':
a.c:6:12: error: argument 1 is null but the corresponding size argument 2 value
is 4096 [-Werror=nonnull]
    6 |     return getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
      |            ^~~~~~~~~~~~~~~~~~~~~~
In file included from a.c:2:
/usr/include/unistd.h:520:14: note: in a call to function 'getcwd' declared
with attribute 'write_only (1, 2)'
  520 | extern char *getcwd (char *__buf, size_t __size) __THROW __wur
      |              ^~~~~~
cc1: some warnings being treated as errors

I see https://sourceware.org/PR26545 where there is a discussion of possibly
changing the behaviour of the function.

I'm opening the bug to consider at least removing the warning whic the
behaviour is valid

Thanks!.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/27476] getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull
  2021-02-26 18:01 [Bug libc/27476] New: getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull slyfox at inbox dot ru
@ 2021-02-26 18:47 ` sam at gentoo dot org
  2021-04-12  7:35 ` eb at emlix dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: sam at gentoo dot org @ 2021-02-26 18:47 UTC (permalink / raw)
  To: glibc-bugs

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

Sam James <sam at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sam at gentoo dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/27476] getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull
  2021-02-26 18:01 [Bug libc/27476] New: getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull slyfox at inbox dot ru
  2021-02-26 18:47 ` [Bug libc/27476] " sam at gentoo dot org
@ 2021-04-12  7:35 ` eb at emlix dot com
  2021-09-08 22:54 ` aurelien at aurel32 dot net
  2021-09-10 20:45 ` glaubitz at physik dot fu-berlin.de
  3 siblings, 0 replies; 5+ messages in thread
From: eb at emlix dot com @ 2021-04-12  7:35 UTC (permalink / raw)
  To: glibc-bugs

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

Rolf Eike Beer <eb at emlix dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eb at emlix dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/27476] getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull
  2021-02-26 18:01 [Bug libc/27476] New: getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull slyfox at inbox dot ru
  2021-02-26 18:47 ` [Bug libc/27476] " sam at gentoo dot org
  2021-04-12  7:35 ` eb at emlix dot com
@ 2021-09-08 22:54 ` aurelien at aurel32 dot net
  2021-09-10 20:45 ` glaubitz at physik dot fu-berlin.de
  3 siblings, 0 replies; 5+ messages in thread
From: aurelien at aurel32 dot net @ 2021-09-08 22:54 UTC (permalink / raw)
  To: glibc-bugs

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

Aurelien Jarno <aurelien at aurel32 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aurelien at aurel32 dot net

--- Comment #1 from Aurelien Jarno <aurelien at aurel32 dot net> ---
Proposed patch here:
https://sourceware.org/pipermail/libc-alpha/2021-September/130857.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/27476] getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull
  2021-02-26 18:01 [Bug libc/27476] New: getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull slyfox at inbox dot ru
                   ` (2 preceding siblings ...)
  2021-09-08 22:54 ` aurelien at aurel32 dot net
@ 2021-09-10 20:45 ` glaubitz at physik dot fu-berlin.de
  3 siblings, 0 replies; 5+ messages in thread
From: glaubitz at physik dot fu-berlin.de @ 2021-09-10 20:45 UTC (permalink / raw)
  To: glibc-bugs

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

John Paul Adrian Glaubitz <glaubitz at physik dot fu-berlin.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |glaubitz at physik dot fu-berlin.d
                   |                            |e

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-10 20:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26 18:01 [Bug libc/27476] New: getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull slyfox at inbox dot ru
2021-02-26 18:47 ` [Bug libc/27476] " sam at gentoo dot org
2021-04-12  7:35 ` eb at emlix dot com
2021-09-08 22:54 ` aurelien at aurel32 dot net
2021-09-10 20:45 ` glaubitz at physik dot fu-berlin.de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).