The tools so far have been using the strerror_r() GNU variant, that returns a string, be it the buffer passed or something else. But that, besides being tricky in cases where we expect that the function using strerror_r() returns the error formatted in a provided buffer (we have to check if it returned something else and copy that instead), breaks the build on systems not using glibc, like Alpine Linux, where musl libc is used. So, introduce yet another wrapper, str_error_r(), that has the GNU interface, but uses the portable XSI variant of strerror_r(), so that users rest asured that the provided buffer is used and it is what is returned.
Unified · Split
| @@ -12,4 +12,6 @@ int strtobool(const char *s, bool *res); · 11 unmodified lines | ||
| 12 | 12 | extern size_t strlcpy(char *dest, const char *src, size_t size); |
| 13 | 13 | #endif |
| 14 | 14 | |
| 15 | +char *str_error_r(int errnum, char *buf, size_t buflen); | |
| 16 | + | |
| 15 | 17 | #endif /* _LINUX_STRING_H_ */ |
| @@ -0,0 +1,26 @@ | ||
| 1 | +#undef _GNU_SOURCE | |
| 2 | +#include <string.h> | |
| 3 | +#include <stdio.h> | |
| 4 | +#include <linux/string.h> | |
| 5 | + | |
| 6 | +/* | |
| 7 | + * The tools so far have been using the strerror_r() GNU variant, that returns | |
| 8 | + * a string, be it the buffer passed or something else. | |
| 9 | + * | |
| 10 | + * But that, besides being tricky in cases where we expect that the function | |
| 11 | + * using strerror_r() returns the error formatted in a provided buffer (we have | |
| 12 | + * to check if it returned something else and copy that instead), breaks the | |
| 13 | + * build on systems not using glibc, like Alpine Linux, where musl libc is | |
| 14 | + * used. | |
| 15 | + * | |
| 16 | + * So, introduce yet another wrapper, str_error_r(), that has the GNU | |
| 17 | + * interface, but uses the portable XSI variant of strerror_r(), so that users | |
| 18 | + * rest asured that the provided buffer is used and it is what is returned. | |
| 19 | + */ | |
| 20 | +char *str_error_r(int errnum, char *buf, size_t buflen) | |
| 21 | +{ | |
| 22 | + int err = strerror_r(errnum, buf, buflen); | |
| 23 | + if (err) | |
| 24 | + snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err); | |
| 25 | + return buf; | |
| 26 | +} | |
| @@ -29,6 +29,7 @@ tools/lib/symbol/kallsyms.c · 28 unmodified lines | ||
| 29 | 29 | tools/lib/symbol/kallsyms.h |
| 30 | 30 | tools/lib/find_bit.c |
| 31 | 31 | tools/lib/bitmap.c |
| 32 | +tools/lib/str_error_r.c | |
| 32 | 33 | tools/include/asm/atomic.h |
| 33 | 34 | tools/include/asm/barrier.h |
| 34 | 35 | tools/include/asm/bug.h |
| @@ -111,14 +111,14 @@ static int __test__rdpmc(void) · 110 unmodified lines | ||
| 111 | 111 | if (fd < 0) { |
| 112 | 112 | pr_err("Error: sys_perf_event_open() syscall returned " |
| 113 | 113 | "with %d (%s)\n", fd, |
| 114 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 114 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 115 | 115 | return -1; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | addr = mmap(NULL, page_size, PROT_READ, MAP_SHARED, fd, 0); |
| 119 | 119 | if (addr == (void *)(-1)) { |
| 120 | 120 | pr_err("Error: mmap() syscall returned with (%s)\n", |
| 121 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 121 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 122 | 122 | goto out_close; |
| 123 | 123 | } |
| 124 | 124 | |
| @@ -351,7 +351,7 @@ int cmd_buildid_cache(int argc, const char **argv, · 350 unmodified lines | ||
| 351 | 351 | continue; |
| 352 | 352 | } |
| 353 | 353 | pr_warning("Couldn't add %s: %s\n", |
| 354 | − pos->s, strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 354 | + pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | strlist__delete(list); |
| @@ -369,7 +369,7 @@ int cmd_buildid_cache(int argc, const char **argv, · 11 unmodified lines | ||
| 369 | 369 | continue; |
| 370 | 370 | } |
| 371 | 371 | pr_warning("Couldn't remove %s: %s\n", |
| 372 | − pos->s, strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 372 | + pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | strlist__delete(list); |
| @@ -387,7 +387,7 @@ int cmd_buildid_cache(int argc, const char **argv, · 11 unmodified lines | ||
| 387 | 387 | continue; |
| 388 | 388 | } |
| 389 | 389 | pr_warning("Couldn't remove %s: %s\n", |
| 390 | − pos->s, strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 390 | + pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | strlist__delete(list); |
| @@ -408,7 +408,7 @@ int cmd_buildid_cache(int argc, const char **argv, · 14 unmodified lines | ||
| 408 | 408 | continue; |
| 409 | 409 | } |
| 410 | 410 | pr_warning("Couldn't update %s: %s\n", |
| 411 | − pos->s, strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 411 | + pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | strlist__delete(list); |
| @@ -117,7 +117,7 @@ static void exec_woman_emacs(const char *path, const char *page) · 116 unmodified lines | ||
| 117 | 117 | free(man_page); |
| 118 | 118 | } |
| 119 | 119 | warning("failed to exec '%s': %s", path, |
| 120 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 120 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| @@ -150,7 +150,7 @@ static void exec_man_konqueror(const char *path, const char *page) · 26 unmodified lines | ||
| 150 | 150 | free(man_page); |
| 151 | 151 | } |
| 152 | 152 | warning("failed to exec '%s': %s", path, |
| 153 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 153 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| @@ -162,7 +162,7 @@ static void exec_man_man(const char *path, const char *page) · 5 unmodified lines | ||
| 162 | 162 | path = "man"; |
| 163 | 163 | execlp(path, "man", page, NULL); |
| 164 | 164 | warning("failed to exec '%s': %s", path, |
| 165 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 165 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | static void exec_man_cmd(const char *cmd, const char *page) |
| @@ -175,7 +175,7 @@ static void exec_man_cmd(const char *cmd, const char *page) · 6 unmodified lines | ||
| 175 | 175 | free(shell_cmd); |
| 176 | 176 | } |
| 177 | 177 | warning("failed to exec '%s': %s", cmd, |
| 178 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 178 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | static void add_man_viewer(const char *name) |
| @@ -1018,13 +1018,13 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm) · 1017 unmodified lines | ||
| 1018 | 1018 | err = perf_evlist__open(evlist); |
| 1019 | 1019 | if (err < 0) { |
| 1020 | 1020 | printf("Couldn't create the events: %s\n", |
| 1021 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 1021 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 1022 | 1022 | goto out; |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | if (perf_evlist__mmap(evlist, kvm->opts.mmap_pages, false) < 0) { |
| 1026 | 1026 | ui__error("Failed to mmap the events: %s\n", |
| 1027 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 1027 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 1028 | 1028 | perf_evlist__close(evlist); |
| 1029 | 1029 | goto out; |
| 1030 | 1030 | } |
| @@ -308,7 +308,7 @@ static void pr_err_with_code(const char *msg, int err) · 307 unmodified lines | ||
| 308 | 308 | |
| 309 | 309 | pr_err("%s", msg); |
| 310 | 310 | pr_debug(" Reason: %s (Code: %d)", |
| 311 | − strerror_r(-err, sbuf, sizeof(sbuf)), err); | |
| 311 | + str_error_r(-err, sbuf, sizeof(sbuf)), err); | |
| 312 | 312 | pr_err("\n"); |
| 313 | 313 | } |
| 314 | 314 | |
| @@ -361,7 +361,7 @@ static int record__mmap_evlist(struct record *rec, · 360 unmodified lines | ||
| 361 | 361 | return -errno; |
| 362 | 362 | } else { |
| 363 | 363 | pr_err("failed to mmap with %d (%s)\n", errno, |
| 364 | − strerror_r(errno, msg, sizeof(msg))); | |
| 364 | + str_error_r(errno, msg, sizeof(msg))); | |
| 365 | 365 | if (errno) |
| 366 | 366 | return -errno; |
| 367 | 367 | else |
| @@ -407,7 +407,7 @@ try_again: · 39 unmodified lines | ||
| 407 | 407 | if (perf_evlist__apply_filters(evlist, &pos)) { |
| 408 | 408 | error("failed to set filter \"%s\" on event %s with %d (%s)\n", |
| 409 | 409 | pos->filter, perf_evsel__name(pos), errno, |
| 410 | − strerror_r(errno, msg, sizeof(msg))); | |
| 410 | + str_error_r(errno, msg, sizeof(msg))); | |
| 411 | 411 | rc = -1; |
| 412 | 412 | goto out; |
| 413 | 413 | } |
| @@ -1003,7 +1003,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) · 589 unmodified lines | ||
| 1003 | 1003 | |
| 1004 | 1004 | if (forks && workload_exec_errno) { |
| 1005 | 1005 | char msg[STRERR_BUFSIZE]; |
| 1006 | − const char *emsg = strerror_r(workload_exec_errno, msg, sizeof(msg)); | |
| 1006 | + const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); | |
| 1007 | 1007 | pr_err("Workload failed: %s\n", emsg); |
| 1008 | 1008 | err = -1; |
| 1009 | 1009 | goto out_child; |
| @@ -494,7 +494,7 @@ force_again: · 493 unmodified lines | ||
| 494 | 494 | } |
| 495 | 495 | pr_err("Error: sys_perf_event_open() syscall returned " |
| 496 | 496 | "with %d (%s)\n%s", fd, |
| 497 | − strerror_r(errno, sbuf, sizeof(sbuf)), info); | |
| 497 | + str_error_r(errno, sbuf, sizeof(sbuf)), info); | |
| 498 | 498 | exit(EXIT_FAILURE); |
| 499 | 499 | } |
| 500 | 500 | return fd; |
| @@ -596,7 +596,7 @@ try_again: · 595 unmodified lines | ||
| 596 | 596 | if (perf_evlist__apply_filters(evsel_list, &counter)) { |
| 597 | 597 | error("failed to set filter \"%s\" on event %s with %d (%s)\n", |
| 598 | 598 | counter->filter, perf_evsel__name(counter), errno, |
| 599 | − strerror_r(errno, msg, sizeof(msg))); | |
| 599 | + str_error_r(errno, msg, sizeof(msg))); | |
| 600 | 600 | return -1; |
| 601 | 601 | } |
| 602 | 602 | |
| @@ -637,7 +637,7 @@ try_again: · 34 unmodified lines | ||
| 637 | 637 | wait(&status); |
| 638 | 638 | |
| 639 | 639 | if (workload_exec_errno) { |
| 640 | − const char *emsg = strerror_r(workload_exec_errno, msg, sizeof(msg)); | |
| 640 | + const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); | |
| 641 | 641 | pr_err("Workload failed: %s\n", emsg); |
| 642 | 642 | return -1; |
| 643 | 643 | } |
| @@ -907,7 +907,7 @@ try_again: · 906 unmodified lines | ||
| 907 | 907 | |
| 908 | 908 | if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) { |
| 909 | 909 | ui__error("Failed to mmap with %d (%s)\n", |
| 910 | − errno, strerror_r(errno, msg, sizeof(msg))); | |
| 910 | + errno, str_error_r(errno, msg, sizeof(msg))); | |
| 911 | 911 | goto out_err; |
| 912 | 912 | } |
| 913 | 913 | |
| @@ -1028,7 +1028,7 @@ out_delete: · 114 unmodified lines | ||
| 1028 | 1028 | |
| 1029 | 1029 | out_err_cpu_topo: { |
| 1030 | 1030 | char errbuf[BUFSIZ]; |
| 1031 | − const char *err = strerror_r(-ret, errbuf, sizeof(errbuf)); | |
| 1031 | + const char *err = str_error_r(-ret, errbuf, sizeof(errbuf)); | |
| 1032 | 1032 | |
| 1033 | 1033 | ui__error("Could not read the CPU topology map: %s\n", err); |
| 1034 | 1034 | goto out_delete; |
| @@ -1295,7 +1295,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) · 260 unmodified lines | ||
| 1295 | 1295 | |
| 1296 | 1296 | if (perf_evlist__create_maps(top.evlist, target) < 0) { |
| 1297 | 1297 | ui__error("Couldn't create thread/CPU maps: %s\n", |
| 1298 | − errno == ENOENT ? "No such process" : strerror_r(errno, errbuf, sizeof(errbuf))); | |
| 1298 | + errno == ENOENT ? "No such process" : str_error_r(errno, errbuf, sizeof(errbuf))); | |
| 1299 | 1299 | goto out_delete_evlist; |
| 1300 | 1300 | } |
| 1301 | 1301 | |
| @@ -1601,7 +1601,7 @@ signed_print: · 1600 unmodified lines | ||
| 1601 | 1601 | fprintf(trace->output, ") = %ld", ret); |
| 1602 | 1602 | } else if (ret < 0 && (sc->fmt->errmsg || sc->fmt->errpid)) { |
| 1603 | 1603 | char bf[STRERR_BUFSIZE]; |
| 1604 | − const char *emsg = strerror_r(-ret, bf, sizeof(bf)), | |
| 1604 | + const char *emsg = str_error_r(-ret, bf, sizeof(bf)), | |
| 1605 | 1605 | *e = audit_errno_to_name(-ret); |
| 1606 | 1606 | |
| 1607 | 1607 | fprintf(trace->output, ") = -1 %s %s", e, emsg); |
| @@ -2402,7 +2402,7 @@ out_error_apply_filters: · 794 unmodified lines | ||
| 2402 | 2402 | fprintf(trace->output, |
| 2403 | 2403 | "Failed to set filter \"%s\" on event %s with %d (%s)\n", |
| 2404 | 2404 | evsel->filter, perf_evsel__name(evsel), errno, |
| 2405 | − strerror_r(errno, errbuf, sizeof(errbuf))); | |
| 2405 | + str_error_r(errno, errbuf, sizeof(errbuf))); | |
| 2406 | 2406 | goto out_delete_evlist; |
| 2407 | 2407 | } |
| 2408 | 2408 | out_error_mem: |
| @@ -374,7 +374,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) · 373 unmodified lines | ||
| 374 | 374 | /* Check for ENOSPC and EIO errors.. */ |
| 375 | 375 | if (fflush(stdout)) { |
| 376 | 376 | fprintf(stderr, "write failure on standard output: %s", |
| 377 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 377 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 378 | 378 | goto out; |
| 379 | 379 | } |
| 380 | 380 | if (ferror(stdout)) { |
| @@ -383,7 +383,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) · 2 unmodified lines | ||
| 383 | 383 | } |
| 384 | 384 | if (fclose(stdout)) { |
| 385 | 385 | fprintf(stderr, "close failed on standard output: %s", |
| 386 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 386 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 387 | 387 | goto out; |
| 388 | 388 | } |
| 389 | 389 | status = 0; |
| @@ -615,7 +615,7 @@ int main(int argc, const char **argv) · 225 unmodified lines | ||
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | fprintf(stderr, "Failed to run command '%s': %s\n", |
| 618 | − cmd, strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 618 | + cmd, str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 619 | 619 | out: |
| 620 | 620 | return 1; |
| 621 | 621 | } |
| @@ -60,7 +60,7 @@ static int do_test(struct perf_evlist *evlist, int mmap_pages, · 59 unmodified lines | ||
| 60 | 60 | err = perf_evlist__mmap(evlist, mmap_pages, true); |
| 61 | 61 | if (err < 0) { |
| 62 | 62 | pr_debug("perf_evlist__mmap: %s\n", |
| 63 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 63 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 64 | 64 | return TEST_FAIL; |
| 65 | 65 | } |
| 66 | 66 | |
| @@ -124,7 +124,7 @@ int test__backward_ring_buffer(int subtest __maybe_unused) · 57 unmodified lines | ||
| 124 | 124 | err = perf_evlist__open(evlist); |
| 125 | 125 | if (err < 0) { |
| 126 | 126 | pr_debug("perf_evlist__open: %s\n", |
| 127 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 127 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 128 | 128 | goto out_delete_evlist; |
| 129 | 129 | } |
| 130 | 130 | |
| @@ -143,14 +143,14 @@ static int do_test(struct bpf_object *obj, int (*func)(void), · 142 unmodified lines | ||
| 143 | 143 | err = perf_evlist__open(evlist); |
| 144 | 144 | if (err < 0) { |
| 145 | 145 | pr_debug("perf_evlist__open: %s\n", |
| 146 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 146 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 147 | 147 | goto out_delete_evlist; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | err = perf_evlist__mmap(evlist, opts.mmap_pages, false); |
| 151 | 151 | if (err < 0) { |
| 152 | 152 | pr_debug("perf_evlist__mmap: %s\n", |
| 153 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 153 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 154 | 154 | goto out_delete_evlist; |
| 155 | 155 | } |
| 156 | 156 | |
| @@ -258,7 +258,7 @@ static int run_test(struct test *test, int subtest) · 257 unmodified lines | ||
| 258 | 258 | |
| 259 | 259 | if (child < 0) { |
| 260 | 260 | pr_err("failed to fork test: %s\n", |
| 261 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 261 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 262 | 262 | return -1; |
| 263 | 263 | } |
| 264 | 264 | |
| @@ -37,7 +37,7 @@ static int attach__enable_on_exec(struct perf_evlist *evlist) · 36 unmodified lines | ||
| 37 | 37 | err = perf_evlist__open(evlist); |
| 38 | 38 | if (err < 0) { |
| 39 | 39 | pr_debug("perf_evlist__open: %s\n", |
| 40 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 40 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 41 | 41 | return err; |
| 42 | 42 | } |
| 43 | 43 | |
| @@ -49,7 +49,7 @@ int test__basic_mmap(int subtest __maybe_unused) · 48 unmodified lines | ||
| 49 | 49 | sched_setaffinity(0, sizeof(cpu_set), &cpu_set); |
| 50 | 50 | if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) { |
| 51 | 51 | pr_debug("sched_setaffinity() failed on CPU %d: %s ", |
| 52 | − cpus->map[0], strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 52 | + cpus->map[0], str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 53 | 53 | goto out_free_cpus; |
| 54 | 54 | } |
| 55 | 55 | |
| @@ -79,7 +79,7 @@ int test__basic_mmap(int subtest __maybe_unused) · 23 unmodified lines | ||
| 79 | 79 | if (perf_evsel__open(evsels[i], cpus, threads) < 0) { |
| 80 | 80 | pr_debug("failed to open counter: %s, " |
| 81 | 81 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
| 82 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 82 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 83 | 83 | goto out_delete_evlist; |
| 84 | 84 | } |
| 85 | 85 | |
| @@ -89,7 +89,7 @@ int test__basic_mmap(int subtest __maybe_unused) · 3 unmodified lines | ||
| 89 | 89 | |
| 90 | 90 | if (perf_evlist__mmap(evlist, 128, true) < 0) { |
| 91 | 91 | pr_debug("failed to mmap events: %d (%s)\n", errno, |
| 92 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 92 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 93 | 93 | goto out_delete_evlist; |
| 94 | 94 | } |
| 95 | 95 | |
| @@ -41,7 +41,7 @@ int test__openat_syscall_event_on_all_cpus(int subtest __maybe_unused) · 40 unmodified lines | ||
| 41 | 41 | if (perf_evsel__open(evsel, cpus, threads) < 0) { |
| 42 | 42 | pr_debug("failed to open counter: %s, " |
| 43 | 43 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
| 44 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 44 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 45 | 45 | goto out_evsel_delete; |
| 46 | 46 | } |
| 47 | 47 | |
| @@ -62,7 +62,7 @@ int test__openat_syscall_event_on_all_cpus(int subtest __maybe_unused) · 14 unmodified lines | ||
| 62 | 62 | if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) { |
| 63 | 63 | pr_debug("sched_setaffinity() failed on CPU %d: %s ", |
| 64 | 64 | cpus->map[cpu], |
| 65 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 65 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 66 | 66 | goto out_close_fd; |
| 67 | 67 | } |
| 68 | 68 | for (i = 0; i < ncalls; ++i) { |
| @@ -51,14 +51,14 @@ int test__syscall_openat_tp_fields(int subtest __maybe_unused) · 50 unmodified lines | ||
| 51 | 51 | err = perf_evlist__open(evlist); |
| 52 | 52 | if (err < 0) { |
| 53 | 53 | pr_debug("perf_evlist__open: %s\n", |
| 54 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 54 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 55 | 55 | goto out_delete_evlist; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | err = perf_evlist__mmap(evlist, UINT_MAX, false); |
| 59 | 59 | if (err < 0) { |
| 60 | 60 | pr_debug("perf_evlist__mmap: %s\n", |
| 61 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 61 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 62 | 62 | goto out_delete_evlist; |
| 63 | 63 | } |
| 64 | 64 | |
| @@ -29,7 +29,7 @@ int test__openat_syscall_event(int subtest __maybe_unused) · 28 unmodified lines | ||
| 29 | 29 | if (perf_evsel__open_per_thread(evsel, threads) < 0) { |
| 30 | 30 | pr_debug("failed to open counter: %s, " |
| 31 | 31 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
| 32 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 32 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 33 | 33 | goto out_evsel_delete; |
| 34 | 34 | } |
| 35 | 35 | |
| @@ -104,7 +104,7 @@ int test__PERF_RECORD(int subtest __maybe_unused) · 103 unmodified lines | ||
| 104 | 104 | err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask); |
| 105 | 105 | if (err < 0) { |
| 106 | 106 | pr_debug("sched__get_first_possible_cpu: %s\n", |
| 107 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 107 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 108 | 108 | goto out_delete_evlist; |
| 109 | 109 | } |
| 110 | 110 | |
| @@ -115,7 +115,7 @@ int test__PERF_RECORD(int subtest __maybe_unused) · 4 unmodified lines | ||
| 115 | 115 | */ |
| 116 | 116 | if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, &cpu_mask) < 0) { |
| 117 | 117 | pr_debug("sched_setaffinity: %s\n", |
| 118 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 118 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 119 | 119 | goto out_delete_evlist; |
| 120 | 120 | } |
| 121 | 121 | |
| @@ -126,7 +126,7 @@ int test__PERF_RECORD(int subtest __maybe_unused) · 4 unmodified lines | ||
| 126 | 126 | err = perf_evlist__open(evlist); |
| 127 | 127 | if (err < 0) { |
| 128 | 128 | pr_debug("perf_evlist__open: %s\n", |
| 129 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 129 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 130 | 130 | goto out_delete_evlist; |
| 131 | 131 | } |
| 132 | 132 | |
| @@ -138,7 +138,7 @@ int test__PERF_RECORD(int subtest __maybe_unused) · 5 unmodified lines | ||
| 138 | 138 | err = perf_evlist__mmap(evlist, opts.mmap_pages, false); |
| 139 | 139 | if (err < 0) { |
| 140 | 140 | pr_debug("perf_evlist__mmap: %s\n", |
| 141 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 141 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 142 | 142 | goto out_delete_evlist; |
| 143 | 143 | } |
| 144 | 144 | |
| @@ -70,7 +70,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) · 69 unmodified lines | ||
| 70 | 70 | |
| 71 | 71 | err = -errno; |
| 72 | 72 | pr_debug("Couldn't open evlist: %s\nHint: check %s, using %" PRIu64 " in this test.\n", |
| 73 | − strerror_r(errno, sbuf, sizeof(sbuf)), | |
| 73 | + str_error_r(errno, sbuf, sizeof(sbuf)), | |
| 74 | 74 | knob, (u64)attr.sample_freq); |
| 75 | 75 | goto out_delete_evlist; |
| 76 | 76 | } |
| @@ -78,7 +78,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) · 1 unmodified line | ||
| 78 | 78 | err = perf_evlist__mmap(evlist, 128, true); |
| 79 | 79 | if (err < 0) { |
| 80 | 80 | pr_debug("failed to mmap event: %d (%s)\n", errno, |
| 81 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 81 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 82 | 82 | goto out_delete_evlist; |
| 83 | 83 | } |
| 84 | 84 | |
| @@ -91,13 +91,13 @@ int test__task_exit(int subtest __maybe_unused) · 90 unmodified lines | ||
| 91 | 91 | err = perf_evlist__open(evlist); |
| 92 | 92 | if (err < 0) { |
| 93 | 93 | pr_debug("Couldn't open the evlist: %s\n", |
| 94 | − strerror_r(-err, sbuf, sizeof(sbuf))); | |
| 94 | + str_error_r(-err, sbuf, sizeof(sbuf))); | |
| 95 | 95 | goto out_delete_evlist; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if (perf_evlist__mmap(evlist, 128, true) < 0) { |
| 99 | 99 | pr_debug("failed to mmap events: %d (%s)\n", errno, |
| 100 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 100 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 101 | 101 | goto out_delete_evlist; |
| 102 | 102 | } |
| 103 | 103 | |
| @@ -2029,7 +2029,7 @@ static int hist_browser__dump(struct hist_browser *browser) · 2028 unmodified lines | ||
| 2029 | 2029 | fp = fopen(filename, "w"); |
| 2030 | 2030 | if (fp == NULL) { |
| 2031 | 2031 | char bf[64]; |
| 2032 | − const char *err = strerror_r(errno, bf, sizeof(bf)); | |
| 2032 | + const char *err = str_error_r(errno, bf, sizeof(bf)); | |
| 2033 | 2033 | ui_helpline__fpush("Couldn't write to %s: %s", filename, err); |
| 2034 | 2034 | return -1; |
| 2035 | 2035 | } |
| @@ -70,6 +70,7 @@ libperf-y += stat.o · 69 unmodified lines | ||
| 70 | 70 | libperf-y += stat-shadow.o |
| 71 | 71 | libperf-y += record.o |
| 72 | 72 | libperf-y += srcline.o |
| 73 | +libperf-y += str_error_r.o | |
| 73 | 74 | libperf-y += data.o |
| 74 | 75 | libperf-y += tsc.o |
| 75 | 76 | libperf-y += cloexec.o |
| @@ -173,6 +174,10 @@ $(OUTPUT)util/libstring.o: ../lib/string.c FORCE · 97 unmodified lines | ||
| 173 | 174 | $(call rule_mkdir) |
| 174 | 175 | $(call if_changed_dep,cc_o_c) |
| 175 | 176 | |
| 177 | +$(OUTPUT)util/str_error_r.o: ../lib/str_error_r.c FORCE | |
| 178 | + $(call rule_mkdir) | |
| 179 | + $(call if_changed_dep,cc_o_c) | |
| 180 | + | |
| 176 | 181 | $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE |
| 177 | 182 | $(call rule_mkdir) |
| 178 | 183 | $(call if_changed_dep,cc_o_c) |
| @@ -1589,7 +1589,7 @@ bpf_loader_strerror(int err, char *buf, size_t size) · 1588 unmodified lines | ||
| 1589 | 1589 | snprintf(buf, size, "Unknown bpf loader error %d", err); |
| 1590 | 1590 | else |
| 1591 | 1591 | snprintf(buf, size, "%s", |
| 1592 | − strerror_r(err, sbuf, sizeof(sbuf))); | |
| 1592 | + str_error_r(err, sbuf, sizeof(sbuf))); | |
| 1593 | 1593 | |
| 1594 | 1594 | buf[size - 1] = '\0'; |
| 1595 | 1595 | return -1; |
| @@ -58,7 +58,7 @@ static int perf_flag_probe(void) · 57 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | WARN_ONCE(err != EINVAL && err != EBUSY, |
| 60 | 60 | "perf_event_open(..., PERF_FLAG_FD_CLOEXEC) failed with unexpected error %d (%s)\n", |
| 61 | − err, strerror_r(err, sbuf, sizeof(sbuf))); | |
| 61 | + err, str_error_r(err, sbuf, sizeof(sbuf))); | |
| 62 | 62 | |
| 63 | 63 | /* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */ |
| 64 | 64 | while (1) { |
| @@ -76,7 +76,7 @@ static int perf_flag_probe(void) · 11 unmodified lines | ||
| 76 | 76 | |
| 77 | 77 | if (WARN_ONCE(fd < 0 && err != EBUSY, |
| 78 | 78 | "perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n", |
| 79 | − err, strerror_r(err, sbuf, sizeof(sbuf)))) | |
| 79 | + err, str_error_r(err, sbuf, sizeof(sbuf)))) | |
| 80 | 80 | return -1; |
| 81 | 81 | |
| 82 | 82 | return 0; |
| @@ -57,7 +57,7 @@ static int open_file_read(struct perf_data_file *file) · 56 unmodified lines | ||
| 57 | 57 | int err = errno; |
| 58 | 58 | |
| 59 | 59 | pr_err("failed to open %s: %s", file->path, |
| 60 | − strerror_r(err, sbuf, sizeof(sbuf))); | |
| 60 | + str_error_r(err, sbuf, sizeof(sbuf))); | |
| 61 | 61 | if (err == ENOENT && !strcmp(file->path, "perf.data")) |
| 62 | 62 | pr_err(" (try 'perf record' first)"); |
| 63 | 63 | pr_err("\n"); |
| @@ -99,7 +99,7 @@ static int open_file_write(struct perf_data_file *file) · 35 unmodified lines | ||
| 99 | 99 | |
| 100 | 100 | if (fd < 0) |
| 101 | 101 | pr_err("failed to open %s : %s\n", file->path, |
| 102 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 102 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 103 | 103 | |
| 104 | 104 | return fd; |
| 105 | 105 | } |
| @@ -38,7 +38,7 @@ extern int debug_data_convert; · 37 unmodified lines | ||
| 38 | 38 | #define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
| 39 | 39 | #define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
| 40 | 40 | |
| 41 | −#define STRERR_BUFSIZE 128 /* For the buffer size of strerror_r */ | |
| 41 | +#define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */ | |
| 42 | 42 | |
| 43 | 43 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
| 44 | 44 | void trace_event(union perf_event *event); |
| @@ -335,7 +335,7 @@ static int do_open(char *name) · 334 unmodified lines | ||
| 335 | 335 | return fd; |
| 336 | 336 | |
| 337 | 337 | pr_debug("dso open failed: %s\n", |
| 338 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 338 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 339 | 339 | if (!dso__data_open_cnt || errno != EMFILE) |
| 340 | 340 | break; |
| 341 | 341 | |
| @@ -786,7 +786,7 @@ static int data_file_size(struct dso *dso, struct machine *machine) · 444 unmodified lines | ||
| 786 | 786 | if (fstat(dso->data.fd, &st) < 0) { |
| 787 | 787 | ret = -errno; |
| 788 | 788 | pr_err("dso cache fstat failed: %s\n", |
| 789 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 789 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 790 | 790 | dso->data.status = DSO_DATA_STATUS_ERROR; |
| 791 | 791 | goto out; |
| 792 | 792 | } |
| @@ -1366,7 +1366,7 @@ int dso__strerror_load(struct dso *dso, char *buf, size_t buflen) · 573 unmodified lines | ||
| 1366 | 1366 | BUG_ON(buflen == 0); |
| 1367 | 1367 | |
| 1368 | 1368 | if (errnum >= 0) { |
| 1369 | − const char *err = strerror_r(errnum, buf, buflen); | |
| 1369 | + const char *err = str_error_r(errnum, buf, buflen); | |
| 1370 | 1370 | |
| 1371 | 1371 | if (err != buf) |
| 1372 | 1372 | scnprintf(buf, buflen, "%s", err); |
| @@ -1790,7 +1790,7 @@ int perf_evlist__strerror_open(struct perf_evlist *evlist, · 1789 unmodified lines | ||
| 1790 | 1790 | int err, char *buf, size_t size) |
| 1791 | 1791 | { |
| 1792 | 1792 | int printed, value; |
| 1793 | − char sbuf[STRERR_BUFSIZE], *emsg = strerror_r(err, sbuf, sizeof(sbuf)); | |
| 1793 | + char sbuf[STRERR_BUFSIZE], *emsg = str_error_r(err, sbuf, sizeof(sbuf)); | |
| 1794 | 1794 | |
| 1795 | 1795 | switch (err) { |
| 1796 | 1796 | case EACCES: |
| @@ -1842,7 +1842,7 @@ out_default: · 45 unmodified lines | ||
| 1842 | 1842 | |
| 1843 | 1843 | int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, size_t size) |
| 1844 | 1844 | { |
| 1845 | − char sbuf[STRERR_BUFSIZE], *emsg = strerror_r(err, sbuf, sizeof(sbuf)); | |
| 1845 | + char sbuf[STRERR_BUFSIZE], *emsg = str_error_r(err, sbuf, sizeof(sbuf)); | |
| 1846 | 1846 | int pages_attempted = evlist->mmap_len / 1024, pages_max_per_user, printed = 0; |
| 1847 | 1847 | |
| 1848 | 1848 | switch (err) { |
| @@ -2419,7 +2419,7 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, · 2418 unmodified lines | ||
| 2419 | 2419 | "The sys_perf_event_open() syscall returned with %d (%s) for event (%s).\n" |
| 2420 | 2420 | "/bin/dmesg may provide additional information.\n" |
| 2421 | 2421 | "No CONFIG_PERF_EVENTS=y kernel support configured?", |
| 2422 | − err, strerror_r(err, sbuf, sizeof(sbuf)), | |
| 2422 | + err, str_error_r(err, sbuf, sizeof(sbuf)), | |
| 2423 | 2423 | perf_evsel__name(evsel)); |
| 2424 | 2424 | } |
| 2425 | 2425 | |
| @@ -106,7 +106,7 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz) · 105 unmodified lines | ||
| 106 | 106 | file = popen(cmd, "r"); |
| 107 | 107 | if (!file) { |
| 108 | 108 | pr_err("ERROR: unable to popen cmd: %s\n", |
| 109 | − strerror_r(errno, serr, sizeof(serr))); | |
| 109 | + str_error_r(errno, serr, sizeof(serr))); | |
| 110 | 110 | return -EINVAL; |
| 111 | 111 | } |
| 112 | 112 | |
| @@ -140,7 +140,7 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz) · 27 unmodified lines | ||
| 140 | 140 | |
| 141 | 141 | if (ferror(file)) { |
| 142 | 142 | pr_err("ERROR: error occurred when reading from pipe: %s\n", |
| 143 | − strerror_r(errno, serr, sizeof(serr))); | |
| 143 | + str_error_r(errno, serr, sizeof(serr))); | |
| 144 | 144 | err = -EIO; |
| 145 | 145 | goto errout; |
| 146 | 146 | } |
| @@ -382,7 +382,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf, · 235 unmodified lines | ||
| 382 | 382 | if (path[0] != '-' && realpath(path, abspath) == NULL) { |
| 383 | 383 | err = errno; |
| 384 | 384 | pr_err("ERROR: problems with path %s: %s\n", |
| 385 | − path, strerror_r(err, serr, sizeof(serr))); | |
| 385 | + path, str_error_r(err, serr, sizeof(serr))); | |
| 386 | 386 | return -err; |
| 387 | 387 | } |
| 388 | 388 | |
| @@ -410,7 +410,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf, · 21 unmodified lines | ||
| 410 | 410 | if (nr_cpus_avail <= 0) { |
| 411 | 411 | pr_err( |
| 412 | 412 | "WARNING:\tunable to get available CPUs in this system: %s\n" |
| 413 | −" \tUse 128 instead.\n", strerror_r(errno, serr, sizeof(serr))); | |
| 413 | +" \tUse 128 instead.\n", str_error_r(errno, serr, sizeof(serr))); | |
| 414 | 414 | nr_cpus_avail = 128; |
| 415 | 415 | } |
| 416 | 416 | snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d", |
| @@ -468,7 +468,7 @@ static struct debuginfo *open_debuginfo(const char *module, bool silent) · 467 unmodified lines | ||
| 468 | 468 | err = kernel_get_module_dso(module, &dso); |
| 469 | 469 | if (err < 0) { |
| 470 | 470 | if (!dso || dso->load_errno == 0) { |
| 471 | − if (!strerror_r(-err, reason, STRERR_BUFSIZE)) | |
| 471 | + if (!str_error_r(-err, reason, STRERR_BUFSIZE)) | |
| 472 | 472 | strcpy(reason, "(unknown)"); |
| 473 | 473 | } else |
| 474 | 474 | dso__strerror_load(dso, reason, STRERR_BUFSIZE); |
| @@ -806,7 +806,7 @@ static int __show_one_line(FILE *fp, int l, bool skip, bool show_num) · 331 unmodified lines | ||
| 806 | 806 | error: |
| 807 | 807 | if (ferror(fp)) { |
| 808 | 808 | pr_warning("File read error: %s\n", |
| 809 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 809 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 810 | 810 | return -1; |
| 811 | 811 | } |
| 812 | 812 | return 0; |
| @@ -886,7 +886,7 @@ static int __show_line_range(struct line_range *lr, const char *module, · 73 unmodified lines | ||
| 886 | 886 | fp = fopen(lr->path, "r"); |
| 887 | 887 | if (fp == NULL) { |
| 888 | 888 | pr_warning("Failed to open %s: %s\n", lr->path, |
| 889 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 889 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 890 | 890 | return -errno; |
| 891 | 891 | } |
| 892 | 892 | /* Skip to starting line number */ |
| @@ -50,7 +50,7 @@ static void print_open_warning(int err, bool uprobe) · 49 unmodified lines | ||
| 50 | 50 | else |
| 51 | 51 | pr_warning("Failed to open %cprobe_events: %s\n", |
| 52 | 52 | uprobe ? 'u' : 'k', |
| 53 | − strerror_r(-err, sbuf, sizeof(sbuf))); | |
| 53 | + str_error_r(-err, sbuf, sizeof(sbuf))); | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | static void print_both_open_warning(int kerr, int uerr) |
| @@ -64,9 +64,9 @@ static void print_both_open_warning(int kerr, int uerr) · 7 unmodified lines | ||
| 64 | 64 | else { |
| 65 | 65 | char sbuf[STRERR_BUFSIZE]; |
| 66 | 66 | pr_warning("Failed to open kprobe events: %s.\n", |
| 67 | − strerror_r(-kerr, sbuf, sizeof(sbuf))); | |
| 67 | + str_error_r(-kerr, sbuf, sizeof(sbuf))); | |
| 68 | 68 | pr_warning("Failed to open uprobe events: %s.\n", |
| 69 | − strerror_r(-uerr, sbuf, sizeof(sbuf))); | |
| 69 | + str_error_r(-uerr, sbuf, sizeof(sbuf))); | |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| @@ -224,7 +224,7 @@ int probe_file__add_event(int fd, struct probe_trace_event *tev) · 151 unmodified lines | ||
| 224 | 224 | if (write(fd, buf, strlen(buf)) < (int)strlen(buf)) { |
| 225 | 225 | ret = -errno; |
| 226 | 226 | pr_warning("Failed to write event: %s\n", |
| 227 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 227 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | free(buf); |
| @@ -262,7 +262,7 @@ static int __del_trace_probe_event(int fd, struct str_node *ent) · 31 unmodified lines | ||
| 262 | 262 | return 0; |
| 263 | 263 | error: |
| 264 | 264 | pr_warning("Failed to delete event: %s\n", |
| 265 | − strerror_r(-ret, buf, sizeof(buf))); | |
| 265 | + str_error_r(-ret, buf, sizeof(buf))); | |
| 266 | 266 | return ret; |
| 267 | 267 | } |
| 268 | 268 | |
| @@ -381,7 +381,7 @@ formatted: · 380 unmodified lines | ||
| 381 | 381 | if (ret >= 16) |
| 382 | 382 | ret = -E2BIG; |
| 383 | 383 | pr_warning("Failed to convert variable type: %s\n", |
| 384 | − strerror_r(-ret, sbuf, sizeof(sbuf))); | |
| 384 | + str_error_r(-ret, sbuf, sizeof(sbuf))); | |
| 385 | 385 | return ret; |
| 386 | 386 | } |
| 387 | 387 | tvar->type = strdup(buf); |
| @@ -809,7 +809,7 @@ static int find_lazy_match_lines(struct intlist *list, · 421 unmodified lines | ||
| 809 | 809 | fp = fopen(fname, "r"); |
| 810 | 810 | if (!fp) { |
| 811 | 811 | pr_warning("Failed to open %s: %s\n", fname, |
| 812 | − strerror_r(errno, sbuf, sizeof(sbuf))); | |
| 812 | + str_error_r(errno, sbuf, sizeof(sbuf))); | |
| 813 | 813 | return -errno; |
| 814 | 814 | } |
| 815 | 815 | |
| @@ -13,6 +13,7 @@ util/cpumap.c · 12 unmodified lines | ||
| 13 | 13 | ../lib/bitmap.c |
| 14 | 14 | ../lib/find_bit.c |
| 15 | 15 | ../lib/hweight.c |
| 16 | +../lib/str_error_r.c | |
| 16 | 17 | util/thread_map.c |
| 17 | 18 | util/util.c |
| 18 | 19 | util/xyarray.c |
| @@ -121,7 +121,7 @@ int target__strerror(struct target *target, int errnum, · 120 unmodified lines | ||
| 121 | 121 | BUG_ON(buflen == 0); |
| 122 | 122 | |
| 123 | 123 | if (errnum >= 0) { |
| 124 | − const char *err = strerror_r(errnum, buf, buflen); | |
| 124 | + const char *err = str_error_r(errnum, buf, buflen); | |
| 125 | 125 | |
| 126 | 126 | if (err != buf) |
| 127 | 127 | scnprintf(buf, buflen, "%s", err); |
| @@ -360,4 +360,5 @@ typedef void (*print_binary_t)(enum binary_printer_ops, · 359 unmodified lines | ||
| 360 | 360 | void print_binary(unsigned char *data, size_t len, |
| 361 | 361 | size_t bytes_per_line, print_binary_t printer, |
| 362 | 362 | void *extra); |
| 363 | + | |
| 363 | 364 | #endif /* GIT_COMPAT_UTIL_H */ |