Build error with GCC 10 in NetworkInterface.c and k_standard.c
Koichi Sakata
sakatakui at oss.nttdata.com
Wed Jul 22 14:48:48 UTC 2020
Hi Andrew,
Thank you for teaching me.
I made the patch that returns NaN. Could you please sponsor it?
In this case I think it is better to fix k_standard.c itself rather than
ignoring the warning. However, I was able to learn there are some good
ways to suppress warnings. So I'd like to thank Ioi and Yasumasa.
Thanks,
Koichi
===== PATCH =====
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 / zero;
+ errno = EINVAL;
+ break;
}
return exc.retval;
}
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;
On 2020/07/22 17:24, Andrew Haley wrote:
> On 17/07/2020 12:26, Koichi Sakata wrote:
>>
>> > 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.
>
> I think it'd be better to fix it. Although the logic is such that all of
> the cases are covered by the switch statement in k_standard.c, the default
> case should return NaN in retval: use zero/zero.
>
> I'll approve that.
>
More information about the core-libs-dev
mailing list