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

Update Port.cpp and omrsharedhelper.c to fix gcc11 compilation #7192

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

pshipton
Copy link
Member

The code fails to compile on zlinux with gcc 11.2 without fixes.

Port.cpp: In static member function 'static RCType
Port::omrfile_stat(const char*, unsigned int, J9FileStat*)':
Port.cpp:691:14: error: narrowing conversion of '4283649346' from
'unsigned int' to 'int'
[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wnarrowing]
  691 |         case 0xFF534D42: /* CIFS_MAGIC_NUMBER */
      |              ^~~~~~~~~~

This one fails to compile on 32-bit.

In file included from /usr/include/string.h:637,
                 from ./unix/omrsharedhelper.c:34:
./unix/omrsharedhelper.c: In function 'omr_unlinkControlFile':
./unix/omrsharedhelper.c:419:9: error: '__builtin_strncpy' specified
bound depends on the length of the source argument
[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstringop-truncation]
  419 |         strncpy(originalErrMsg, currentErrMsg, msgLen);
      |         ^~~~~~~
./unix/omrsharedhelper.c:413:26: note: length computed here
  413 |         int32_t msgLen = strlen(currentErrMsg);
      |                          ^~~~~~~~~~~~~~~~~~~~~

tools/tracegen/Port.cpp Outdated Show resolved Hide resolved
The code fails to compile on zlinux with gcc 11.2 without fixes.
```
Port.cpp: In static member function 'static RCType
Port::omrfile_stat(const char*, unsigned int, J9FileStat*)':
Port.cpp:691:14: error: narrowing conversion of '4283649346' from
'unsigned int' to 'int'
[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wnarrowing]
  691 |         case 0xFF534D42: /* CIFS_MAGIC_NUMBER */
      |              ^~~~~~~~~~
```

This one fails to compile on 32-bit.
```
In file included from /usr/include/string.h:637,
                 from ./unix/omrsharedhelper.c:34:
./unix/omrsharedhelper.c: In function 'omr_unlinkControlFile':
./unix/omrsharedhelper.c:419:9: error: '__builtin_strncpy' specified
bound depends on the length of the source argument
[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstringop-truncation]
  419 |         strncpy(originalErrMsg, currentErrMsg, msgLen);
      |         ^~~~~~~
./unix/omrsharedhelper.c:413:26: note: length computed here
  413 |         int32_t msgLen = strlen(currentErrMsg);
      |                          ^~~~~~~~~~~~~~~~~~~~~
```

Signed-off-by: Peter Shipton <Peter_Shipton@ca.ibm.com>
@babsingh
Copy link
Contributor

jenkins build all

@babsingh
Copy link
Contributor

PR builds look good. Only the below known failure is seen.

@babsingh babsingh merged commit 3ec3aa7 into eclipse:master Nov 30, 2023
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants