OpenJDK / jdk / jdk
changeset 51120:dccdf51b10dd
8207233: Minor improvements of jdk C-coding
Reviewed-by: rriggs, prr
author | goetz |
---|---|
date | Fri, 13 Jul 2018 17:42:24 +0200 |
parents | a602706ccaaa |
children | 44483330f7cf |
files | src/java.base/share/native/libzip/zip_util.c src/java.desktop/unix/native/common/awt/fontpath.c src/java.smartcardio/share/native/libj2pcsc/pcsc.c src/jdk.crypto.ec/share/native/libsunec/impl/ecl_mult.c src/jdk.jdwp.agent/share/native/libjdwp/transport.c src/jdk.pack/share/native/common-unpack/unpack.cpp src/jdk.security.auth/unix/native/libjaas/Unix.c |
diffstat | 7 files changed, 20 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java.base/share/native/libzip/zip_util.c Fri Jul 13 13:00:36 2018 -0700 +++ b/src/java.base/share/native/libzip/zip_util.c Fri Jul 13 17:42:24 2018 +0200 @@ -739,13 +739,13 @@ jzfile *zip = NULL; /* Clear zip error message */ - if (pmsg != 0) { + if (pmsg != NULL) { *pmsg = NULL; } zip = ZIP_Get_From_Cache(name, pmsg, lastModified); - if (zip == NULL && *pmsg == NULL) { + if (zip == NULL && pmsg != NULL && *pmsg == NULL) { ZFILE zfd = ZFILE_Open(name, mode); zip = ZIP_Put_In_Cache(name, zfd, pmsg, lastModified); }
--- a/src/java.desktop/unix/native/common/awt/fontpath.c Fri Jul 13 13:00:36 2018 -0700 +++ b/src/java.desktop/unix/native/common/awt/fontpath.c Fri Jul 13 17:42:24 2018 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. 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 @@ -265,7 +265,7 @@ } - newFontPath = SAFE_SIZE_ARRAY_ALLOC(malloc, totalDirCount, sizeof ( char **) ); + newFontPath = SAFE_SIZE_ARRAY_ALLOC(malloc, totalDirCount, sizeof(char *)); /* if it fails free things and get out */ if ( newFontPath == NULL ) { free ( ( void *) appendDirList );
--- a/src/java.smartcardio/share/native/libj2pcsc/pcsc.c Fri Jul 13 13:00:36 2018 -0700 +++ b/src/java.smartcardio/share/native/libj2pcsc/pcsc.c Fri Jul 13 17:42:24 2018 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2018, Oracle and/or its affiliates. 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 @@ -192,7 +192,7 @@ } dprintf1("-size: %d\n", size); - if (size) { + if (size != 0) { mszReaders = malloc(size); if (mszReaders == NULL) { throwOutOfMemoryError(env, NULL); @@ -205,6 +205,8 @@ return NULL; } dprintf1("-String: %s\n", mszReaders); + } else { + return NULL; } result = pcsc_multi2jstring(env, mszReaders);
--- a/src/jdk.crypto.ec/share/native/libsunec/impl/ecl_mult.c Fri Jul 13 13:00:36 2018 -0700 +++ b/src/jdk.crypto.ec/share/native/libsunec/impl/ecl_mult.c Fri Jul 13 17:42:24 2018 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * * This library is free software; you can redistribute it and/or @@ -80,12 +80,12 @@ group, timing)); } } else { + kt.flag = (mp_sign)0; if (group->meth->field_enc) { MP_CHECKOK(group->meth->field_enc(px, rx, group->meth)); MP_CHECKOK(group->meth->field_enc(py, ry, group->meth)); MP_CHECKOK(group->point_mul(&kt, rx, ry, rx, ry, group, timing)); } else { - kt.flag = (mp_sign)0; MP_CHECKOK(group->point_mul(&kt, px, py, rx, ry, group, timing)); } }
--- a/src/jdk.jdwp.agent/share/native/libjdwp/transport.c Fri Jul 13 13:00:36 2018 -0700 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/transport.c Fri Jul 13 17:42:24 2018 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. 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 @@ -211,7 +211,7 @@ JNI_FUNC_PTR(env,GetJavaVM)(env, &jvm); /* Try version 1.1 first, fallback to 1.0 on error */ - for (i = 0; i < sizeof(supported_versions); ++i) { + for (i = 0; i < sizeof(supported_versions)/sizeof(jint); ++i) { rc = (*onLoad)(jvm, &callback, supported_versions[i], &t); if (rc != JNI_EVERSION) { info->transportVersion = supported_versions[i];
--- a/src/jdk.pack/share/native/common-unpack/unpack.cpp Fri Jul 13 13:00:36 2018 -0700 +++ b/src/jdk.pack/share/native/common-unpack/unpack.cpp Fri Jul 13 17:42:24 2018 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. 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 @@ -2681,6 +2681,9 @@ PRINTCR((1, "counted %d [redefined = %d predefined = %d] attributes of type %s.%s", count, isRedefined(idx), isPredefined(idx), ATTR_CONTEXT_NAME[attrc], lo->name)); + } else { + abort("layout_definition pointer must not be NULL"); + return; } bool hasCallables = lo->hasCallables(); band** bands = lo->bands();
--- a/src/jdk.security.auth/unix/native/libjaas/Unix.c Fri Jul 13 13:00:36 2018 -0700 +++ b/src/jdk.security.auth/unix/native/libjaas/Unix.c Fri Jul 13 17:42:24 2018 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. 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 @@ -64,6 +64,9 @@ jclass cls; numSuppGroups = getgroups(0, NULL); + if (numSuppGroups == -1) { + return; + } groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t)); if (groups == NULL) { jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");