From b9e177677cf55822898ab141bea015c6fc60b54c Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Tue, 23 Jul 2019 16:52:38 +0200 Subject: [PATCH] 8228482: fix xlc16/xlclang comparison of distinct pointer types and string literal conversion warnings Reviewed-by: clanger, mdoerr --- src/hotspot/os/aix/libodm_aix.cpp | 6 +++--- src/hotspot/os/aix/libodm_aix.hpp | 16 +++++++++------- src/hotspot/os/aix/os_aix.cpp | 2 +- src/java.base/aix/native/libjli/java_md_aix.c | 3 +-- .../unix/native/libnet/NetworkInterface.c | 6 +++++- src/java.desktop/aix/native/libawt/porting_aix.c | 5 ++--- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/hotspot/os/aix/libodm_aix.cpp b/src/hotspot/os/aix/libodm_aix.cpp index af998b84086..1306ddb0dd2 100644 --- a/src/hotspot/os/aix/libodm_aix.cpp +++ b/src/hotspot/os/aix/libodm_aix.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2015 SAP SE. All rights reserved. + * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ dynamicOdm::~dynamicOdm() { void odmWrapper::clean_data() { if (_data) { free(_data); _data = NULL; } } -int odmWrapper::class_offset(char *field, bool is_aix_5) +int odmWrapper::class_offset(const char *field, bool is_aix_5) { assert(has_class(), "initialization"); for (int i = 0; i < odm_class()->nelem; i++) { diff --git a/src/hotspot/os/aix/libodm_aix.hpp b/src/hotspot/os/aix/libodm_aix.hpp index 00bd38d91a5..709e57f48d9 100644 --- a/src/hotspot/os/aix/libodm_aix.hpp +++ b/src/hotspot/os/aix/libodm_aix.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2015 SAP SE. All rights reserved. + * Copyright (c) 2015, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,13 +68,15 @@ class odmWrapper : private dynamicOdm { public: // Make sure everything gets initialized and cleaned up properly. - explicit odmWrapper(char* odm_class_name, char* odm_path = NULL) : _odm_class((CLASS_SYMBOL)-1), + explicit odmWrapper(const char* odm_class_name, const char* odm_path = NULL) : _odm_class((CLASS_SYMBOL)-1), _data(NULL), _initialized(false) { if (!odm_loaded()) { return; } _initialized = ((*_odm_initialize)() != -1); if (_initialized) { - if (odm_path) { (*_odm_set_path)(odm_path); } - _odm_class = (*_odm_mount_class)(odm_class_name); + // should we free what odm_set_path returns, man page suggests it + // see https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/o_bostechref/odm_set_path.html + if (odm_path) { (*_odm_set_path)((char*)odm_path); } + _odm_class = (*_odm_mount_class)((char*)odm_class_name); } } ~odmWrapper() { @@ -83,12 +85,12 @@ class odmWrapper : private dynamicOdm { CLASS_SYMBOL odm_class() { return _odm_class; } bool has_class() { return odm_class() != (CLASS_SYMBOL)-1; } - int class_offset(char *field, bool is_aix_5); + int class_offset(const char *field, bool is_aix_5); char* data() { return _data; } - char* retrieve_obj(char* name = NULL) { + char* retrieve_obj(const char* name = NULL) { clean_data(); - char *cnp = (char*)(void*)(*_odm_get_obj)(odm_class(), name, NULL, (name == NULL) ? ODM_NEXT : ODM_FIRST); + char *cnp = (char*)(void*)(*_odm_get_obj)(odm_class(), (char*) name, NULL, (name == NULL) ? ODM_NEXT : ODM_FIRST); if (cnp != (char*)-1) { _data = cnp; } return data(); } diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index 26fc3e1bfff..4eecb813c3c 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -4228,7 +4228,7 @@ extern char** environ; // Unlike system(), this function can be called from signal handler. It // doesn't block SIGINT et al. int os::fork_and_exec(char* cmd, bool use_vfork_if_available) { - char * argv[4] = {"sh", "-c", cmd, NULL}; + char* argv[4] = { (char*)"sh", (char*)"-c", cmd, NULL}; pid_t pid = fork(); diff --git a/src/java.base/aix/native/libjli/java_md_aix.c b/src/java.base/aix/native/libjli/java_md_aix.c index 8990b2cdb51..e9cd827801f 100644 --- a/src/java.base/aix/native/libjli/java_md_aix.c +++ b/src/java.base/aix/native/libjli/java_md_aix.c @@ -39,8 +39,7 @@ static int dladdr_dont_reload(void *addr, Dl_info *info) { memset((void *)info, 0, sizeof(Dl_info)); for (;;) { if (addr >= p->ldinfo_textorg && - addr < (((char*)p->ldinfo_textorg) + p->ldinfo_textsize)) - { + addr < p->ldinfo_textorg + p->ldinfo_textsize) { info->dli_fname = p->ldinfo_filename; return 1; } diff --git a/src/java.base/unix/native/libnet/NetworkInterface.c b/src/java.base/unix/native/libnet/NetworkInterface.c index a9e1cf7b66a..244bc3244f9 100644 --- a/src/java.base/unix/native/libnet/NetworkInterface.c +++ b/src/java.base/unix/native/libnet/NetworkInterface.c @@ -1394,6 +1394,10 @@ static int getFlags(int sock, const char *ifname, int *flags) { /** AIX **/ #if defined(_AIX) +/* seems getkerninfo is guarded by _KERNEL in the system headers */ +/* see net/proto_uipc.h */ +int getkerninfo(int, char *, int *, int32long64_t); + /* * Opens a socket for further ioctl calls. Tries AF_INET socket first and * if it fails return AF_INET6 socket. @@ -1613,7 +1617,7 @@ static int getMacAddress return -1; } - if (getkerninfo(KINFO_NDD, nddp, &size, 0) < 0) { + if (getkerninfo(KINFO_NDD, (char*) nddp, &size, 0) < 0) { perror("getkerninfo 2"); free(nddp); return -1; diff --git a/src/java.desktop/aix/native/libawt/porting_aix.c b/src/java.desktop/aix/native/libawt/porting_aix.c index 5c8004ecc13..0f05071cb37 100644 --- a/src/java.desktop/aix/native/libawt/porting_aix.c +++ b/src/java.desktop/aix/native/libawt/porting_aix.c @@ -43,11 +43,10 @@ static void fill_dll_info(void) { static int dladdr_dont_reload(void* addr, Dl_info* info) { const struct ld_info* p = (struct ld_info*) dladdr_buffer; - info->dli_fbase = 0; info->dli_fname = 0; - info->dli_sname = 0; info->dli_saddr = 0; + memset((void *)info, 0, sizeof(Dl_info)); for (;;) { if (addr >= p->ldinfo_textorg && - addr < (((char*)p->ldinfo_textorg) + p->ldinfo_textsize)) { + addr < p->ldinfo_textorg + p->ldinfo_textsize) { info->dli_fname = p->ldinfo_filename; info->dli_fbase = p->ldinfo_textorg; return 1; /* [sic] */