Newer glibc versions return const char for strchr() when the 's' arg is
const, change the return variable to const to match that.
Also we don't need to turn that ',' into a '\0', as strtol() will stop
in the first invalid char. No need to touch read only memory.
First noticed with fedora 44.
Reviewed-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20251211221756.96294-3-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
}
};
-static int setup_compute_opt_wdiff(char *opt)
+static int setup_compute_opt_wdiff(const char *opt)
{
- char *w1_str = opt;
- char *w2_str;
+ const char *w1_str = opt, *w2_str;
int ret = -EINVAL;
if (!w2_str)
goto out;
- *w2_str++ = 0x0;
- if (!*w2_str)
+ if (!*++w2_str)
goto out;
compute_wdiff_w1 = strtol(w1_str, NULL, 10);
return ret;
}
-static int setup_compute_opt(char *opt)
+static int setup_compute_opt(const char *opt)
{
if (compute == COMPUTE_WEIGHTED_DIFF)
return setup_compute_opt_wdiff(opt);
char *cstr = (char *) str;
char buf[50];
unsigned i;
- char *option;
+ const char *option;
if (!str) {
*cp = COMPUTE_DELTA;