Skip to content

Include fcntl.h so AT_FDCWD does not get redefined.#563

Closed
collinfunk wants to merge 1 commit intoopenssh:masterfrom
collinfunk:dont-redefine-at_fdcwd
Closed

Include fcntl.h so AT_FDCWD does not get redefined.#563
collinfunk wants to merge 1 commit intoopenssh:masterfrom
collinfunk:dont-redefine-at_fdcwd

Conversation

@collinfunk
Copy link
Copy Markdown
Contributor

The bsd-misc.h header will define AT_FDCWD and implement the *at functions to set errno = ENOSYS, which is reasonable on systems lacking them.

However, before defining AT_FDCWD, <fcntl.h> should be included where POSIX requires it to be defined [1].

The following GCC warning should make things clear:

In file included from port-net.c:27:
/usr/include/fcntl.h:149:10: warning: "AT_FDCWD" redefined
  149 | # define AT_FDCWD               -100    /* Special value used to indicate
      |          ^~~~~~~~
In file included from ../openbsd-compat/openbsd-compat.h:218:
../openbsd-compat/bsd-misc.h:69:10: note: this is the location of the previous definition
   69 | # define AT_FDCWD (-2)
      |          ^~~~~~~~

configure.ac already has AC_CHECK_HEADERS([fcntl.h]), so just adding the include fixes it.

[1] https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/fcntl.h.html

@daztucker
Copy link
Copy Markdown
Contributor

Applied, thanks.

@daztucker daztucker closed this Mar 27, 2025
@collinfunk collinfunk deleted the dont-redefine-at_fdcwd branch March 27, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants