Date: Mon, 17 Jul 2023 15:48:47 GMT From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: ed942d5a1738 - stable/13 - seq: combine asprintf return value checks Message-ID: <202307171548.36HFml3V080017@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ed942d5a173870e786fd422c9edfbe5037626b4b commit ed942d5a173870e786fd422c9edfbe5037626b4b Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2023-06-19 02:10:32 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2023-07-17 15:48:28 +0000 seq: combine asprintf return value checks Error handling is identical for all of these failure cases. Sponsored by: The FreeBSD Foundation (cherry picked from commit 5dae8905a5141e0cba1f4f3f94116440a5ce2abb) --- usr.bin/seq/seq.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/usr.bin/seq/seq.c b/usr.bin/seq/seq.c index 50c6b6022967..e5350690c703 100644 --- a/usr.bin/seq/seq.c +++ b/usr.bin/seq/seq.c @@ -198,13 +198,9 @@ main(int argc, char *argv[]) * equal, it means the exit condition of the loop held true due to a * rounding error and we still need to print 'last'. */ - if (asprintf(&cur_print, fmt, cur) < 0) { - err(1, "asprintf"); - } - if (asprintf(&last_print, fmt, last) < 0) { - err(1, "asprintf"); - } - if (asprintf(&prev_print, fmt, prev) < 0) { + if (asprintf(&cur_print, fmt, cur) < 0 || + asprintf(&last_print, fmt, last) < 0 || + asprintf(&prev_print, fmt, prev) < 0) { err(1, "asprintf"); } if (strcmp(cur_print, last_print) == 0 &&
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307171548.36HFml3V080017>