Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not unconditionally use PATH_MAX with getcwd #578

Merged
merged 1 commit into from
May 23, 2013
Merged

do not unconditionally use PATH_MAX with getcwd #578

merged 1 commit into from
May 23, 2013

Conversation

pinotree
Copy link
Contributor

Instead, grow a buffer until getcwd either succeeds or fails with an errno different than ERANGE
(meaning the passed buffer was too short to represent the actual path).
Reset errno before calling getcwd to check it eventually did not fail.

This fixes a build failure on GNU/Hurd, which does not provide PATH_MAX (which is optional in POSIX).

Instead, grow a buffer until getcwd either succeeds or fails with an errno different than ERANGE
(meaning the passed buffer was too short to represent the actual path).
Reset errno before calling getcwd to check it eventually did not fail.
@buildhive
Copy link

Evan Martin » ninja #469 SUCCESS
This pull request looks good
(what's this?)

@evmar
Copy link
Collaborator

evmar commented May 21, 2013

Looking through the code, I see some other mentions of MAX_PATH -- do you know about the portability of that?
(It appears to maybe only be in Windows-specific code.)

@pinotree
Copy link
Contributor Author

After my changes, the only PATH_MAX occurrency I see is in src/util.h, in a #ifdef _MSC_VER block -- possibly no more useful, but I have no Windows environment to test its removal.

@evmar
Copy link
Collaborator

evmar commented May 21, 2013

Right, I'm talking about MAX_PATH, not PATH_MAX. It's very confusing, which is why I'm asking you. :)

@pinotree
Copy link
Contributor Author

From what I know, MAX_PATH is nothing standard and just provided on Windows.

evmar added a commit that referenced this pull request May 23, 2013
do not unconditionally use PATH_MAX with getcwd
@evmar evmar merged commit 6eeb53f into ninja-build:master May 23, 2013
@evmar
Copy link
Collaborator

evmar commented May 23, 2013

Thanks for the patch!

@evmar evmar mentioned this pull request May 23, 2013
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.

3 participants