8207233: Minor improvements of jdk C-coding

Reviewed-by: rriggs, prr
This commit is contained in:
Goetz Lindenmaier 2018-07-13 17:42:24 +02:00
parent 93364e9a43
commit fc20a5d86b
7 changed files with 20 additions and 12 deletions

View file

@ -739,13 +739,13 @@ ZIP_Open_Generic(const char *name, char **pmsg, int mode, jlong lastModified)
jzfile *zip = NULL; jzfile *zip = NULL;
/* Clear zip error message */ /* Clear zip error message */
if (pmsg != 0) { if (pmsg != NULL) {
*pmsg = NULL; *pmsg = NULL;
} }
zip = ZIP_Get_From_Cache(name, pmsg, lastModified); 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); ZFILE zfd = ZFILE_Open(name, mode);
zip = ZIP_Put_In_Cache(name, zfd, pmsg, lastModified); zip = ZIP_Put_In_Cache(name, zfd, pmsg, lastModified);
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -265,7 +265,7 @@ static void AddFontsToX11FontPath ( fDirRecord *fDirP )
} }
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 it fails free things and get out */
if ( newFontPath == NULL ) { if ( newFontPath == NULL ) {
free ( ( void *) appendDirList ); free ( ( void *) appendDirList );

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -192,7 +192,7 @@ JNIEXPORT jobjectArray JNICALL Java_sun_security_smartcardio_PCSC_SCardListReade
} }
dprintf1("-size: %d\n", size); dprintf1("-size: %d\n", size);
if (size) { if (size != 0) {
mszReaders = malloc(size); mszReaders = malloc(size);
if (mszReaders == NULL) { if (mszReaders == NULL) {
throwOutOfMemoryError(env, NULL); throwOutOfMemoryError(env, NULL);
@ -205,6 +205,8 @@ JNIEXPORT jobjectArray JNICALL Java_sun_security_smartcardio_PCSC_SCardListReade
return NULL; return NULL;
} }
dprintf1("-String: %s\n", mszReaders); dprintf1("-String: %s\n", mszReaders);
} else {
return NULL;
} }
result = pcsc_multi2jstring(env, mszReaders); result = pcsc_multi2jstring(env, mszReaders);

View file

@ -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. * Use is subject to license terms.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -80,12 +80,12 @@ ECPoint_mul(const ECGroup *group, const mp_int *k, const mp_int *px,
group, timing)); group, timing));
} }
} else { } else {
kt.flag = (mp_sign)0;
if (group->meth->field_enc) { if (group->meth->field_enc) {
MP_CHECKOK(group->meth->field_enc(px, rx, group->meth)); MP_CHECKOK(group->meth->field_enc(px, rx, group->meth));
MP_CHECKOK(group->meth->field_enc(py, ry, group->meth)); MP_CHECKOK(group->meth->field_enc(py, ry, group->meth));
MP_CHECKOK(group->point_mul(&kt, rx, ry, rx, ry, group, timing)); MP_CHECKOK(group->point_mul(&kt, rx, ry, rx, ry, group, timing));
} else { } else {
kt.flag = (mp_sign)0;
MP_CHECKOK(group->point_mul(&kt, px, py, rx, ry, group, timing)); MP_CHECKOK(group->point_mul(&kt, px, py, rx, ry, group, timing));
} }
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -211,7 +211,7 @@ loadTransport(const char *name, TransportInfo *info)
JNI_FUNC_PTR(env,GetJavaVM)(env, &jvm); JNI_FUNC_PTR(env,GetJavaVM)(env, &jvm);
/* Try version 1.1 first, fallback to 1.0 on error */ /* 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); rc = (*onLoad)(jvm, &callback, supported_versions[i], &t);
if (rc != JNI_EVERSION) { if (rc != JNI_EVERSION) {
info->transportVersion = supported_versions[i]; info->transportVersion = supported_versions[i];

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -2681,6 +2681,9 @@ void unpacker::attr_definitions::readBandData(int idx) {
PRINTCR((1, "counted %d [redefined = %d predefined = %d] attributes of type %s.%s", PRINTCR((1, "counted %d [redefined = %d predefined = %d] attributes of type %s.%s",
count, isRedefined(idx), isPredefined(idx), count, isRedefined(idx), isPredefined(idx),
ATTR_CONTEXT_NAME[attrc], lo->name)); ATTR_CONTEXT_NAME[attrc], lo->name));
} else {
abort("layout_definition pointer must not be NULL");
return;
} }
bool hasCallables = lo->hasCallables(); bool hasCallables = lo->hasCallables();
band** bands = lo->bands(); band** bands = lo->bands();

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -64,6 +64,9 @@ Java_com_sun_security_auth_module_UnixSystem_getUnixInfo
jclass cls; jclass cls;
numSuppGroups = getgroups(0, NULL); numSuppGroups = getgroups(0, NULL);
if (numSuppGroups == -1) {
return;
}
groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t)); groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t));
if (groups == NULL) { if (groups == NULL) {
jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError"); jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");