Build error with GCC 10 in NetworkInterface.c and k_standard.c
David Holmes
david.holmes at oracle.com
Fri Jul 17 14:05:32 UTC 2020
If you are going to change makefiles you need to get review on
build-dev at openjdk.java.net :)
David
On 17/07/2020 11:48 pm, Yasumasa Suenaga wrote:
> Hi Koichi,
>
> On 2020/07/17 20:26, Koichi Sakata wrote:
>> Hi Daniel,
>>
>> > The changes to NetworkInterface.c look good to me.
>>
>> Thank you.
>>
>> > You'll need to find a reviewer that understands what that
>> > method is supposed to do in that case, that's not me ;-)
>>
>> I understand. This ML is suitable for finding a reviewer, isn't it?
>> Or, there is another way. We can avoid the error by the accepting
>> maybe-uninitialized warning in libfdlibm instead of fixing k_standard.c.
>>
>> diff --git a/make/modules/java.base/lib/CoreLibraries.gmk
>> b/make/modules/java.base/lib/CoreLibraries.gmk
>> --- a/make/modules/java.base/lib/CoreLibraries.gmk
>> +++ b/make/modules/java.base/lib/CoreLibraries.gmk
>> @@ -48,7 +48,7 @@
>> CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \
>> CFLAGS_windows_debug := -DLOGGING, \
>> CFLAGS_aix := -qfloat=nomaf, \
>> - DISABLED_WARNINGS_gcc := sign-compare misleading-indentation
>> array-bounds, \
>> + DISABLED_WARNINGS_gcc := sign-compare misleading-indentation
>> array-bounds maybe-uninitialized, \
>> DISABLED_WARNINGS_clang := sign-compare, \
>> DISABLED_WARNINGS_microsoft := 4146 4244 4018, \
>> ARFLAGS := $(ARFLAGS), \
>
> This change affects all of C sources in core-libs.
> So I think it is better affect to k_standard.c only as below:
>
> ```
> diff --git a/make/modules/java.base/lib/CoreLibraries.gmk
> b/make/modules/java.base/lib/CoreLibraries.gmk
> --- a/make/modules/java.base/lib/CoreLibraries.gmk
> +++ b/make/modules/java.base/lib/CoreLibraries.gmk
> @@ -39,6 +39,10 @@
> LIBFDLIBM_SRC := $(TOPDIR)/src/java.base/share/native/libfdlibm
> LIBFDLIBM_CFLAGS := -I$(LIBFDLIBM_SRC) $(FDLIBM_CFLAGS)
>
> +ifeq ($(call isTargetOs, linux), true)
> + BUILD_LIBFDLIBM_k_standard.c_CFLAGS += -Wno-maybe-uninitialized
> +endif
> +
> $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \
> NAME := fdlibm, \
> TYPE := STATIC_LIBRARY, \
> ```
>
> You can pass compiler option to specified file.
>
>
> Thanks,
>
> Yasumasa
>
>
>> Thanks,
>> Koichi
>>
>> On 2020/07/15 3:36, Daniel Fuchs wrote:
>>> Hi Koichi,
>>>
>>> On 13/07/2020 08:03, Koichi Sakata wrote:
>>> > I understand that. I respect your idea.
>>> > I fixed the patch as follows.
>>> The changes to NetworkInterface.c look good to me.
>>>
>>> >
>>> > By the way, k_standard.c still remains. Is there a way to proceed
>>> with it?
>>>
>>> You'll need to find a reviewer that understands what that
>>> method is supposed to do in that case, that's not me ;-)
>>>
>>> best regards,
>>>
>>> -- daniel
>>>
>>>> Thanks, > Koichi
>>>>
>>>> ===== PATCH =====
>>>> diff --git a/src/java.base/unix/native/libnet/NetworkInterface.c
>>>> b/src/java.base/unix/native/libnet/NetworkInterface.c
>>>> --- a/src/java.base/unix/native/libnet/NetworkInterface.c
>>>> +++ b/src/java.base/unix/native/libnet/NetworkInterface.c
>>>> @@ -1296,7 +1296,8 @@
>>>> static int getIndex(int sock, const char *name) {
>>>> struct ifreq if2;
>>>> memset((char *)&if2, 0, sizeof(if2));
>>>> - strncpy(if2.ifr_name, name, sizeof(if2.ifr_name) - 1);
>>>> + strncpy(if2.ifr_name, name, sizeof(if2.ifr_name));
>>>> + if2.ifr_name[sizeof(if2.ifr_name) - 1] = 0;
>>>>
>>>> if (ioctl(sock, SIOCGIFINDEX, (char *)&if2) < 0) {
>>>> return -1;
>>>> @@ -1359,7 +1360,8 @@
>>>> static int getFlags(int sock, const char *ifname, int *flags) {
>>>> struct ifreq if2;
>>>> memset((char *)&if2, 0, sizeof(if2));
>>>> - strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
>>>> + strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name));
>>>> + if2.ifr_name[sizeof(if2.ifr_name) - 1] = 0;
>>>>
>>>> if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
>>>> return -1;
>>>> diff --git a/src/java.base/share/native/libfdlibm/k_standard.c
>>>> b/src/java.base/share/native/libfdlibm/k_standard.c
>>>> --- a/src/java.base/share/native/libfdlibm/k_standard.c
>>>> +++ b/src/java.base/share/native/libfdlibm/k_standard.c
>>>> @@ -739,6 +739,10 @@
>>>> errno = EDOM;
>>>> }
>>>> break;
>>>> + default:
>>>> + exc.retval = zero;
>>>> + errno = EINVAL;
>>>> + break;
>>>> }
>>>> return exc.retval;
>>>> }
>>>>
>>>>
>>>
More information about the core-libs-dev
mailing list