From cb385e7c80a2926ac9c9fe50e5e0c60665fb022c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 18 Jun 2024 13:24:19 -0400 Subject: Use dstrx*() over dstrn*() when we know the exact length --- src/color.c | 12 ++++++------ src/exec.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/color.c b/src/color.c index 81f28bb..701a89c 100644 --- a/src/color.c +++ b/src/color.c @@ -583,7 +583,7 @@ static int parse_gnu_ls_colors(struct colors *colors, const char *ls_colors) { break; } - if (dstrncpy(&key, chunk, equals - chunk) != 0) { + if (dstrxcpy(&key, chunk, equals - chunk) != 0) { goto fail; } if (unescape(&value, equals + 1, ':', &next) != 0) { @@ -968,7 +968,7 @@ static ssize_t first_broken_offset(const char *path, const struct BFTW *ftwbuf, if (path == ftwbuf->path) { if (ftwbuf->depth == 0) { at_fd = AT_FDCWD; - at_path = dstrndup(path, max); + at_path = dstrxdup(path, max); } else { // The parent must have existed to get here goto out; @@ -977,13 +977,13 @@ static ssize_t first_broken_offset(const char *path, const struct BFTW *ftwbuf, // We're in print_link_target(), so resolve relative to the link's parent directory at_fd = ftwbuf->at_fd; if (at_fd == (int)AT_FDCWD && path[0] != '/') { - at_path = dstrndup(ftwbuf->path, ftwbuf->nameoff); - if (at_path && dstrncat(&at_path, path, max) != 0) { + at_path = dstrxdup(ftwbuf->path, ftwbuf->nameoff); + if (at_path && dstrxcat(&at_path, path, max) != 0) { ret = -1; goto out_path; } } else { - at_path = dstrndup(path, max); + at_path = dstrxdup(path, max); } } @@ -1206,7 +1206,7 @@ static int cvbuff(CFILE *cfile, const char *format, va_list args) { for (const char *i = format; *i; ++i) { size_t verbatim = strcspn(i, "%$"); - if (dstrncat(&cfile->buffer, i, verbatim) != 0) { + if (dstrxcat(&cfile->buffer, i, verbatim) != 0) { return -1; } i += verbatim; diff --git a/src/exec.c b/src/exec.c index cd73d6c..2faa731 100644 --- a/src/exec.c +++ b/src/exec.c @@ -234,7 +234,7 @@ static char *bfs_exec_format_arg(char *arg, const char *path) { char *last = arg; do { - if (dstrncat(&ret, last, match - last) != 0) { + if (dstrxcat(&ret, last, match - last) != 0) { goto err; } if (dstrcat(&ret, path) != 0) { -- cgit v1.2.3