Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/java.base/share/native/libjli/java.c
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ static void
SetMainModule(const char *s)
{
static const char format[] = "-Djdk.module.main=%s";
char* slash = JLI_StrChr(s, '/');
const char* slash = JLI_StrChr(s, '/');
size_t s_len, def_len;
char *def;

Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/native/libjli/jli_util.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2026, 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
Expand Down Expand Up @@ -87,7 +87,7 @@ JLI_MemFree(void *ptr)
jboolean
JLI_HasSuffix(const char *s1, const char *s2)
{
char *p = JLI_StrRChr(s1, '.');
const char* p = JLI_StrRChr(s1, '.');
if (p == NULL || *p == '\0') {
return JNI_FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/native/libverify/check_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -3832,7 +3832,7 @@ signature_to_fieldtype(context_type *context,
case JVM_SIGNATURE_CLASS: {
char buffer_space[256];
char *buffer = buffer_space;
char *finish = strchr(p, JVM_SIGNATURE_ENDCLASS);
const char* finish = strchr(p, JVM_SIGNATURE_ENDCLASS);
int length;
if (finish == NULL) {
/* Signature must have ';' after the class name.
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/unix/native/libjava/TimeZone_md.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2026, 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
Expand Down Expand Up @@ -95,7 +95,7 @@ getZoneName(char *str)
{
static const char *zidir = "zoneinfo/";

char *pos = strstr((const char *)str, zidir);
char* pos = strstr(str, zidir);
if (pos == NULL) {
return NULL;
}
Expand Down
21 changes: 16 additions & 5 deletions src/java.base/unix/native/libnet/NetworkInterface.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2026, 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
Expand Down Expand Up @@ -58,10 +58,14 @@
#endif

#define CHECKED_MALLOC3(_pointer, _type, _size) \
CHECKED_MALLOC4(_pointer, _type, _size, {})

#define CHECKED_MALLOC4(_pointer, _type, _size, _onFailure) \
do { \
_pointer = (_type)malloc(_size); \
if (_pointer == NULL) { \
JNU_ThrowOutOfMemoryError(env, "Native heap allocation failed"); \
do _onFailure while (0); \
return ifs; /* return untouched list */ \
} \
} while(0)
Expand Down Expand Up @@ -201,7 +205,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0
netif *ifs, *curr;
jboolean isCopy;
const char* name_utf;
char *colonP;
const char* colonP;
jobject obj = NULL;

if (name != NULL) {
Expand Down Expand Up @@ -995,7 +999,7 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs,

// If "new" then create a netif structure and insert it into the list.
if (currif == NULL) {
CHECKED_MALLOC3(currif, netif *, sizeof(netif) + IFNAMESIZE);
CHECKED_MALLOC4(currif, netif *, sizeof(netif) + IFNAMESIZE, { free(addrP); });
currif->name = (char *)currif + sizeof(netif);
strncpy(currif->name, name, IFNAMESIZE);
currif->name[IFNAMESIZE - 1] = '\0';
Expand Down Expand Up @@ -1027,7 +1031,10 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs,
}

if (currif == NULL) {
CHECKED_MALLOC3(currif, netif *, sizeof(netif) + IFNAMESIZE);
CHECKED_MALLOC4(currif, netif *, sizeof(netif) + IFNAMESIZE, {
free(addrP);
free(parent);
});
currif->name = (char *)currif + sizeof(netif);
strncpy(currif->name, vname, IFNAMESIZE);
currif->name[IFNAMESIZE - 1] = '\0';
Expand All @@ -1039,7 +1046,11 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs,
parent->childs = currif;
}

CHECKED_MALLOC3(tmpaddr, netaddr *, sizeof(netaddr) + 2 * addr_size);
CHECKED_MALLOC4(tmpaddr, netaddr *, sizeof(netaddr) + 2 * addr_size, {
free(addrP);
free(parent);
free(currif);
});
memcpy(tmpaddr, addrP, sizeof(netaddr));
if (addrP->addr != NULL) {
tmpaddr->addr = (struct sockaddr *)
Expand Down
4 changes: 2 additions & 2 deletions src/java.instrument/share/native/libinstrument/JPLISAgent.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2026, 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
Expand Down Expand Up @@ -780,7 +780,7 @@ getModuleObject(jvmtiEnv* jvmti,
jobject moduleObject = NULL;

/* find last slash in the class name */
char* last_slash = (cname == NULL) ? NULL : strrchr(cname, '/');
const char* last_slash = (cname == NULL) ? NULL : strrchr(cname, '/');
int len = (last_slash == NULL) ? 0 : (int)(last_slash - cname);
char* pkg_name_buf = (char*)malloc(len + 1);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
Expand Down Expand Up @@ -36,7 +36,7 @@
#define slash '/'

char* basePath(const char* path) {
char* last = strrchr(path, slash);
const char* last = strrchr(path, slash);
if (last == NULL) {
return (char*)path;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2026, 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
Expand Down Expand Up @@ -90,8 +90,8 @@ get_time_stamp(char *tbuf, size_t ltbuf)
static const char *
file_basename(const char *file)
{
char *p1;
char *p2;
const char* p1;
const char* p2;

if ( file==NULL )
return "unknown";
Expand Down
10 changes: 5 additions & 5 deletions src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2026, 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
Expand Down Expand Up @@ -109,7 +109,7 @@ static PackageDesc* initPackageDesc(PackageDesc* desc, const char* str,
#define POPEN_CALLBACK_USE 1
#define POPEN_CALLBACK_IGNORE 0

typedef int (*popenCallbackType)(void*, const char*);
typedef int (*popenCallbackType)(void*, char*);

static int popenCommand(const char* cmdlineFormat, const char* arg,
popenCallbackType callback, void* callbackData) {
Expand Down Expand Up @@ -220,13 +220,13 @@ static char* concat(const char *x, const char *y) {
}


static int initRpmPackage(void* desc, const char* str) {
static int initRpmPackage(void* desc, char* str) {
initPackageDesc((PackageDesc*)desc, str, PACKAGE_TYPE_RPM);
return POPEN_CALLBACK_IGNORE;
}


static int initDebPackage(void* desc, const char* str) {
static int initDebPackage(void* desc, char* str) {
char* colonChrPos = strchr(str, ':');
if (colonChrPos) {
*colonChrPos = 0;
Expand All @@ -238,7 +238,7 @@ static int initDebPackage(void* desc, const char* str) {

#define LAUNCHER_LIB_NAME "/libapplauncher.so"

static int findLauncherLib(void* launcherLibPath, const char* str) {
static int findLauncherLib(void* launcherLibPath, char* str) {
char* buf = 0;
const size_t strLen = strlen(str);
const size_t launcherLibNameLen = strlen(LAUNCHER_LIB_NAME);
Expand Down