Skip to content

Commit

Permalink
Reland "[flang] Fix a warning"
Browse files Browse the repository at this point in the history
This reverts commit 4210eb1.

I didn't realise this was going to break every -Werror bot,
so I guess we'll take the test suite failure until a fix is found,
it's less disruptive.
  • Loading branch information
DavidSpickett committed Jan 12, 2024
1 parent 9fdc568 commit 5b14bd0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions flang/runtime/extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ void FORTRAN_PROCEDURE_NAME(getlog)(std::byte *arg, std::int64_t length) {
if (nameMaxLen == -1)
nameMaxLen = _POSIX_LOGIN_NAME_MAX + 1;
#endif
char str[nameMaxLen];
std::vector<char> str(nameMaxLen);

int error{getlogin_r(str, nameMaxLen)};
int error{getlogin_r(str.data(), nameMaxLen)};
if (error == 0) {
// no error: find first \0 in string then pad from there
CopyAndPad(reinterpret_cast<char *>(arg), str, length, std::strlen(str));
CopyAndPad(reinterpret_cast<char *>(arg), str.data(), length,
std::strlen(str.data()));
} else {
// error occur: get username from environment variable
GetUsernameEnvVar("LOGNAME", arg, length);
Expand Down

0 comments on commit 5b14bd0

Please sign in to comment.