Wed, 05 Mar 2014 11:28:33 -0800
8029775: Solaris code cleanup
Summary: cleaned up warnings in solaris specific os code.
Reviewed-by: coleenp, fparain, dcubed
Contributed-by: gerald.thornbrugh@oracle.com
1.1 --- a/src/os/solaris/vm/os_solaris.cpp Fri Jan 24 09:28:47 2014 +0100 1.2 +++ b/src/os/solaris/vm/os_solaris.cpp Wed Mar 05 11:28:33 2014 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -2232,8 +2232,8 @@ 1.11 st->cr(); 1.12 status = true; 1.13 } 1.14 - ::close(fd); 1.15 } 1.16 + ::close(fd); 1.17 } 1.18 return status; 1.19 } 1.20 @@ -2257,13 +2257,18 @@ 1.21 "ILL_ILLTRP", "ILL_PRVOPC", "ILL_PRVREG", 1.22 "ILL_COPROC", "ILL_BADSTK" }; 1.23 1.24 +const size_t ill_names_length = (sizeof(ill_names)/sizeof(char *)); 1.25 + 1.26 const char *fpe_names[] = { "FPE0", "FPE_INTDIV", "FPE_INTOVF", "FPE_FLTDIV", 1.27 "FPE_FLTOVF", "FPE_FLTUND", "FPE_FLTRES", 1.28 "FPE_FLTINV", "FPE_FLTSUB" }; 1.29 +const size_t fpe_names_length = (sizeof(fpe_names)/sizeof(char *)); 1.30 1.31 const char *segv_names[] = { "SEGV0", "SEGV_MAPERR", "SEGV_ACCERR" }; 1.32 +const size_t segv_names_length = (sizeof(segv_names)/sizeof(char *)); 1.33 1.34 const char *bus_names[] = { "BUS0", "BUS_ADRALN", "BUS_ADRERR", "BUS_OBJERR" }; 1.35 +const size_t bus_names_length = (sizeof(bus_names)/sizeof(char *)); 1.36 1.37 void os::print_siginfo(outputStream* st, void* siginfo) { 1.38 st->print("siginfo:"); 1.39 @@ -2282,19 +2287,23 @@ 1.40 assert(c > 0, "unexpected si_code"); 1.41 switch (si->si_signo) { 1.42 case SIGILL: 1.43 - st->print(", si_code=%d (%s)", c, c > 8 ? "" : ill_names[c]); 1.44 + st->print(", si_code=%d (%s)", c, 1.45 + c >= ill_names_length ? "" : ill_names[c]); 1.46 st->print(", si_addr=" PTR_FORMAT, si->si_addr); 1.47 break; 1.48 case SIGFPE: 1.49 - st->print(", si_code=%d (%s)", c, c > 9 ? "" : fpe_names[c]); 1.50 + st->print(", si_code=%d (%s)", c, 1.51 + c >= fpe_names_length ? "" : fpe_names[c]); 1.52 st->print(", si_addr=" PTR_FORMAT, si->si_addr); 1.53 break; 1.54 case SIGSEGV: 1.55 - st->print(", si_code=%d (%s)", c, c > 2 ? "" : segv_names[c]); 1.56 + st->print(", si_code=%d (%s)", c, 1.57 + c >= segv_names_length ? "" : segv_names[c]); 1.58 st->print(", si_addr=" PTR_FORMAT, si->si_addr); 1.59 break; 1.60 case SIGBUS: 1.61 - st->print(", si_code=%d (%s)", c, c > 3 ? "" : bus_names[c]); 1.62 + st->print(", si_code=%d (%s)", c, 1.63 + c >= bus_names_length ? "" : bus_names[c]); 1.64 st->print(", si_addr=" PTR_FORMAT, si->si_addr); 1.65 break; 1.66 default: 1.67 @@ -3011,7 +3020,7 @@ 1.68 char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found) { 1.69 const uint_t info_types[] = { MEMINFO_VLGRP, MEMINFO_VPAGESIZE }; 1.70 const size_t types = sizeof(info_types) / sizeof(info_types[0]); 1.71 - uint64_t addrs[MAX_MEMINFO_CNT], outdata[types * MAX_MEMINFO_CNT]; 1.72 + uint64_t addrs[MAX_MEMINFO_CNT], outdata[types * MAX_MEMINFO_CNT + 1]; 1.73 uint_t validity[MAX_MEMINFO_CNT]; 1.74 1.75 size_t page_size = MAX2((size_t)os::vm_page_size(), page_expected->size); 1.76 @@ -3050,7 +3059,7 @@ 1.77 } 1.78 } 1.79 1.80 - if (i != addrs_count) { 1.81 + if (i < addrs_count) { 1.82 if ((validity[i] & 2) != 0) { 1.83 page_found->lgrp_id = outdata[types * i]; 1.84 } else {
2.1 --- a/src/os/solaris/vm/perfMemory_solaris.cpp Fri Jan 24 09:28:47 2014 +0100 2.2 +++ b/src/os/solaris/vm/perfMemory_solaris.cpp Wed Mar 05 11:28:33 2014 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -431,10 +431,12 @@ 2.11 2.12 RESTARTABLE(::read(fd, addr, remaining), result); 2.13 if (result == OS_ERR) { 2.14 + ::close(fd); 2.15 THROW_MSG_0(vmSymbols::java_io_IOException(), "Read error"); 2.16 + } else { 2.17 + remaining-=result; 2.18 + addr+=result; 2.19 } 2.20 - remaining-=result; 2.21 - addr+=result; 2.22 } 2.23 2.24 ::close(fd); 2.25 @@ -906,8 +908,16 @@ 2.26 FREE_C_HEAP_ARRAY(char, filename, mtInternal); 2.27 2.28 // open the shared memory file for the give vmid 2.29 - fd = open_sharedmem_file(rfilename, file_flags, CHECK); 2.30 - assert(fd != OS_ERR, "unexpected value"); 2.31 + fd = open_sharedmem_file(rfilename, file_flags, THREAD); 2.32 + 2.33 + if (fd == OS_ERR) { 2.34 + return; 2.35 + } 2.36 + 2.37 + if (HAS_PENDING_EXCEPTION) { 2.38 + ::close(fd); 2.39 + return; 2.40 + } 2.41 2.42 if (*sizep == 0) { 2.43 size = sharedmem_filesize(fd, CHECK);
3.1 --- a/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Fri Jan 24 09:28:47 2014 +0100 3.2 +++ b/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Wed Mar 05 11:28:33 2014 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -475,9 +475,11 @@ 3.11 // here if the underlying file has been truncated. 3.12 // Do not crash the VM in such a case. 3.13 CodeBlob* cb = CodeCache::find_blob_unsafe(pc); 3.14 - nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL; 3.15 - if (nm != NULL && nm->has_unsafe_access()) { 3.16 - stub = StubRoutines::handler_for_unsafe_access(); 3.17 + if (cb != NULL) { 3.18 + nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL; 3.19 + if (nm != NULL && nm->has_unsafe_access()) { 3.20 + stub = StubRoutines::handler_for_unsafe_access(); 3.21 + } 3.22 } 3.23 } 3.24 else 3.25 @@ -724,6 +726,7 @@ 3.26 err.report_and_die(); 3.27 3.28 ShouldNotReachHere(); 3.29 + return false; 3.30 } 3.31 3.32 void os::print_context(outputStream *st, void *context) {