public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "slyfox at inbox dot ru" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/27476] New: getcwd(NULL, PATH_MAX) generates warnings on -Wnonnull Date: Fri, 26 Feb 2021 18:01:41 +0000 [thread overview] Message-ID: <bug-27476-131@http.sourceware.org/bugzilla/> (raw) 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.
next reply other threads:[~2021-02-26 18:01 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-26 18:01 slyfox at inbox dot ru [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-27476-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).