summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Barrié <etienne.barrie@gmail.com>2026-04-21 17:55:22 +0200
committerJohn Hawthorn <john@hawthorn.email>2026-04-22 16:45:35 +0900
commit42b3cdc51a30b4b155f80fb7808e2b0e634dddc1 (patch)
tree1f4b5708cd580cfb2d539f061b02d5be40a06866
parentf6b0f318421b45a46ff83ed1daecd12389512b60 (diff)
Remove discard qualifiers warning with C23 strchr
C23 has qualifier-preserving standard library functions, so calling strchr with a `const char *` will return a `const char *`. We can change the type of the local variables because we don't mutate the strings.
-rw-r--r--hash.c4
-rw-r--r--load.c2
-rw-r--r--ruby.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/hash.c b/hash.c
index 4321f479fd..aee157266f 100644
--- a/hash.c
+++ b/hash.c
@@ -6487,7 +6487,7 @@ env_rassoc(VALUE dmy, VALUE obj)
while (*env) {
const char *p = *env;
- char *s = strchr(p, '=');
+ const char *s = strchr(p, '=');
if (s++) {
long len = strlen(s);
if (RSTRING_LEN(obj) == len && strncmp(s, RSTRING_PTR(obj), len) == 0) {
@@ -6707,7 +6707,7 @@ env_shift(VALUE _)
char **env = GET_ENVIRON(environ);
if (*env) {
const char *p = *env;
- char *s = strchr(p, '=');
+ const char *s = strchr(p, '=');
if (s) {
key = env_str_new(p, s-p, enc);
VALUE val = env_str_new2(getenv(RSTRING_PTR(key)), enc);
diff --git a/load.c b/load.c
index dc03020116..f7bdf07641 100644
--- a/load.c
+++ b/load.c
@@ -1712,7 +1712,7 @@ rb_ext_resolve_symbol(const char* fname, const char* symbol)
VALUE handle;
VALUE resolved;
VALUE path;
- char *ext;
+ const char *ext;
VALUE fname_str = rb_str_new_cstr(fname);
const rb_box_t *box = rb_loading_box();
diff --git a/ruby.c b/ruby.c
index f9f50e99ea..687d769285 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1373,7 +1373,7 @@ proc_0_option(ruby_cmdline_options_t *opt, const char *s)
static void
proc_encoding_option(ruby_cmdline_options_t *opt, const char *s, const char *opt_name)
{
- char *p;
+ const char *p;
# define set_encoding_part(type) \
if (!(p = strchr(s, ':'))) { \
set_##type##_encoding_once(opt, s, 0); \