git: 5dae8905a514 - main - seq: combine asprintf return value checks
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 25 Jun 2023 23:57:33 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=5dae8905a5141e0cba1f4f3f94116440a5ce2abb
commit 5dae8905a5141e0cba1f4f3f94116440a5ce2abb
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-06-19 02:10:32 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-06-25 23:57:17 +0000
seq: combine asprintf return value checks
Error handling is identical for all of these failure cases.
Sponsored by: The FreeBSD Foundation
---
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 3618a106ec9e..d1d2cfbf17ed 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 &&