From: Karel Zak Date: Mon, 30 Jun 2025 09:15:30 +0000 (+0200) Subject: lib/strutils: add ul_ prefix to strrep() and strrem() functions X-Git-Tag: v2.41.2-rc1~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bea88a2e6a0fa67417fc0d01c0df259e0c46e2a4;p=thirdparty%2Futil-linux.git lib/strutils: add ul_ prefix to strrep() and strrem() functions Addresses: https://github.com/util-linux/util-linux/issues/3626 Signed-off-by: Karel Zak (cherry picked from commit 7bb1151e559710f18682454384c99d7cd67f35fb) --- diff --git a/include/strutils.h b/include/strutils.h index c8c616f7b..a7177fc23 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -405,13 +405,13 @@ static inline size_t normalize_whitespace(unsigned char *str) return __normalize_whitespace(str, sz, str, sz + 1); } -static inline void strrep(char *s, int find, int replace) +static inline void ul_strrep(char *s, int find, int replace) { while (s && *s && (s = strchr(s, find)) != NULL) *s++ = replace; } -static inline void strrem(char *s, int rem) +static inline void ul_strrem(char *s, int rem) { char *p; diff --git a/sys-utils/lscpu-cputype.c b/sys-utils/lscpu-cputype.c index 98ad03e71..3937a00a8 100644 --- a/sys-utils/lscpu-cputype.c +++ b/sys-utils/lscpu-cputype.c @@ -961,14 +961,14 @@ int lscpu_read_vulnerabilities(struct lscpu_cxt *cxt) /* Name */ vu->name = xstrdup(d->d_name); *vu->name = toupper(*vu->name); - strrep(vu->name, '_', ' '); + ul_strrep(vu->name, '_', ' '); /* Description */ vu->text = str; p = (char *) ul_startswith(vu->text, "Mitigation"); if (p) { *p = ';'; - strrem(vu->text, ':'); + ul_strrem(vu->text, ':'); } } closedir(dir); diff --git a/term-utils/script-playutils.c b/term-utils/script-playutils.c index 854d95252..8c68ad14c 100644 --- a/term-utils/script-playutils.c +++ b/term-utils/script-playutils.c @@ -359,7 +359,7 @@ static int read_multistream_step(struct replay_step *step, FILE *f, char type) break; } if (*buf) { - strrem(buf, '\n'); + ul_strrem(buf, '\n'); step->value = strrealloc(step->value, buf); if (!step->value) err_oom(); diff --git a/term-utils/script.c b/term-utils/script.c index 90070248d..5b2d6b517 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -824,7 +824,7 @@ int main(int argc, char **argv) case 'c': ctl.command = optarg; ctl.command_norm = xstrdup(ctl.command); - strrep(ctl.command_norm, '\n', ' '); + ul_strrep(ctl.command_norm, '\n', ' '); break; case 'E': if (strcmp(optarg, "auto") == 0)