On Thu, 19 Sep 2024 04:24:09 GMT, David Holmes <dhol...@openjdk.org> wrote:
>> Simon Tooke has updated the pull request incrementally with one additional >> commit since the last revision: >> >> remove tabs > > test/hotspot/gtest/runtime/test_os.cpp line 433: > >> 431: errno = 0; >> 432: returnedBuffer = os::realpath(tmppath, buffer, MAX_PATH); >> 433: EXPECT_TRUE(returnedBuffer == buffer); > > Should we also do `EXPECT_TRUE(errno == 0);` ? Here and below. This is interesting! I found that on Linux, errno _was not zero_! The specifications for POSIX realpath say `RETURN VALUE Upon successful completion, realpath() shall return a pointer to the resolved name. Otherwise, realpath() shall return a null pointer and set errno to indicate the error, and the contents of the buffer pointed to by resolved_name are undefined.` Nowhere does it say errno is unchanged if successful. errno = 0; ::printf("before ::realpath("/tmp",nullptr) errno=%d\n", errno); char* p = ::realpath("/tmp", nullptr); ::printf("after ::realpath p=%s errno=%d\n", p, errno); outputs: before ::realpath("/tmp",nullptr) errno=0 after ::realpath /tmp p=/tmp errno=22 With behaviour like this, one can see why OpenJDK wraps ::realpath()... Compiler used: g++ (GCC) 14.2.1 20240801 ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20683#discussion_r1766296852