git: a8ddd1926a34 - main - date: Fix a few nits.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 Sep 2024 17:32:46 UTC
The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=a8ddd1926a34fc20970d9ceaad71b31fc414b1c5 commit a8ddd1926a34fc20970d9ceaad71b31fc414b1c5 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2024-09-04 17:32:23 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2024-09-04 17:32:23 +0000 date: Fix a few nits. * Don't use `asprintf()` when `strdup()` can do the job just as well. * Fix a couple of typos in a comment. Fixes: eeb04a736cb9 MFC after: 3 days Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D46533 --- bin/date/date.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/date/date.c b/bin/date/date.c index 3ce9ee3235fb..01797084c0d6 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -382,8 +382,8 @@ strftime_ns(char * __restrict s, size_t maxsize, const char * __restrict format, bool seen_percent; seen_percent = false; - if (asprintf(&newformat, "%s", format) < 0) - err(1, "asprintf"); + if ((newformat = strdup(format)) == NULL) + err(1, "strdup"); tok = newformat; for (tok = newformat; *tok != '\0'; tok++) { switch (*tok) { @@ -405,9 +405,9 @@ strftime_ns(char * __restrict s, size_t maxsize, const char * __restrict format, suffix = tok + 1; /* * Construct a new format string from the - * prefix (i.e., the part of the old fromat + * prefix (i.e., the part of the old format * from its beginning to the currently handled - * "%N" conversion specification, the + * "%N" conversion specification), the * nanoseconds, and the suffix (i.e., the part * of the old format from the next token to the * end).