diff options
| author | Étienne Barrié <etienne.barrie@gmail.com> | 2026-04-21 17:55:22 +0200 |
|---|---|---|
| committer | John Hawthorn <john@hawthorn.email> | 2026-04-22 16:45:35 +0900 |
| commit | 42b3cdc51a30b4b155f80fb7808e2b0e634dddc1 (patch) | |
| tree | 1f4b5708cd580cfb2d539f061b02d5be40a06866 | |
| parent | f6b0f318421b45a46ff83ed1daecd12389512b60 (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.c | 4 | ||||
| -rw-r--r-- | load.c | 2 | ||||
| -rw-r--r-- | ruby.c | 2 |
3 files changed, 4 insertions, 4 deletions
@@ -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); @@ -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(); @@ -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); \ |
