Skip to content

Commit c6388b2

Browse files
fthevenetjerboaa
authored andcommitted
8378180: Compiling OpenJDK with C23 C-Compiler gives warning: initialization discards ‘const’ qualifier from pointer target type
Backport-of: 76a44b3e0341a9c59eaff0bfe8884ad104bda8d5
1 parent 42174d8 commit c6388b2

9 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/java.base/share/native/libjli/java.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ static void
10581058
SetMainModule(const char *s)
10591059
{
10601060
static const char format[] = "-Djdk.module.main=%s";
1061-
char* slash = JLI_StrChr(s, '/');
1061+
const char* slash = JLI_StrChr(s, '/');
10621062
size_t s_len, def_len;
10631063
char *def;
10641064

src/java.base/share/native/libjli/jli_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -87,7 +87,7 @@ JLI_MemFree(void *ptr)
8787
jboolean
8888
JLI_HasSuffix(const char *s1, const char *s2)
8989
{
90-
char *p = JLI_StrRChr(s1, '.');
90+
const char* p = JLI_StrRChr(s1, '.');
9191
if (p == NULL || *p == '\0') {
9292
return JNI_FALSE;
9393
}

src/java.base/share/native/libverify/check_code.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3832,7 +3832,7 @@ signature_to_fieldtype(context_type *context,
38323832
case JVM_SIGNATURE_CLASS: {
38333833
char buffer_space[256];
38343834
char *buffer = buffer_space;
3835-
char *finish = strchr(p, JVM_SIGNATURE_ENDCLASS);
3835+
const char* finish = strchr(p, JVM_SIGNATURE_ENDCLASS);
38363836
int length;
38373837
if (finish == NULL) {
38383838
/* Signature must have ';' after the class name.

src/java.base/unix/native/libjava/TimeZone_md.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -95,7 +95,7 @@ getZoneName(char *str)
9595
{
9696
static const char *zidir = "zoneinfo/";
9797

98-
char *pos = strstr((const char *)str, zidir);
98+
char* pos = strstr(str, zidir);
9999
if (pos == NULL) {
100100
return NULL;
101101
}

src/java.base/unix/native/libnet/NetworkInterface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -205,7 +205,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0
205205
netif *ifs, *curr;
206206
jboolean isCopy;
207207
const char* name_utf;
208-
char *colonP;
208+
const char* colonP;
209209
jobject obj = NULL;
210210

211211
if (name != NULL) {

src/java.instrument/share/native/libinstrument/JPLISAgent.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -780,7 +780,7 @@ getModuleObject(jvmtiEnv* jvmti,
780780
jobject moduleObject = NULL;
781781

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

src/java.instrument/unix/native/libinstrument/FileSystemSupport_md.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
3636
#define slash '/'
3737

3838
char* basePath(const char* path) {
39-
char* last = strrchr(path, slash);
39+
const char* last = strrchr(path, slash);
4040
if (last == NULL) {
4141
return (char*)path;
4242
} else {

src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -90,8 +90,8 @@ get_time_stamp(char *tbuf, size_t ltbuf)
9090
static const char *
9191
file_basename(const char *file)
9292
{
93-
char *p1;
94-
char *p2;
93+
const char* p1;
94+
const char* p2;
9595

9696
if ( file==NULL )
9797
return "unknown";

src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -109,7 +109,7 @@ static PackageDesc* initPackageDesc(PackageDesc* desc, const char* str,
109109
#define POPEN_CALLBACK_USE 1
110110
#define POPEN_CALLBACK_IGNORE 0
111111

112-
typedef int (*popenCallbackType)(void*, const char*);
112+
typedef int (*popenCallbackType)(void*, char*);
113113

114114
static int popenCommand(const char* cmdlineFormat, const char* arg,
115115
popenCallbackType callback, void* callbackData) {
@@ -220,13 +220,13 @@ static char* concat(const char *x, const char *y) {
220220
}
221221

222222

223-
static int initRpmPackage(void* desc, const char* str) {
223+
static int initRpmPackage(void* desc, char* str) {
224224
initPackageDesc((PackageDesc*)desc, str, PACKAGE_TYPE_RPM);
225225
return POPEN_CALLBACK_IGNORE;
226226
}
227227

228228

229-
static int initDebPackage(void* desc, const char* str) {
229+
static int initDebPackage(void* desc, char* str) {
230230
char* colonChrPos = strchr(str, ':');
231231
if (colonChrPos) {
232232
*colonChrPos = 0;
@@ -238,7 +238,7 @@ static int initDebPackage(void* desc, const char* str) {
238238

239239
#define LAUNCHER_LIB_NAME "/libapplauncher.so"
240240

241-
static int findLauncherLib(void* launcherLibPath, const char* str) {
241+
static int findLauncherLib(void* launcherLibPath, char* str) {
242242
char* buf = 0;
243243
const size_t strLen = strlen(str);
244244
const size_t launcherLibNameLen = strlen(LAUNCHER_LIB_NAME);

0 commit comments

Comments
 (0)