[PATCH iproute2-next v1 4/6] iplink_can: use invarg() instead of fprintf()
From: Vincent Mailhol
Date: Tue Nov 12 2024 - 12:30:48 EST
invarg() is specifically designed to print error messages when an
invalid argument is provided. Replace the generic fprintf() by
invarg() in can_parse_opt().
Signed-off-by: Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>
---
ip/iplink_can.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/ip/iplink_can.c b/ip/iplink_can.c
index 6c6fcf61..928d5d79 100644
--- a/ip/iplink_can.c
+++ b/ip/iplink_can.c
@@ -254,10 +254,8 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,
cm.mask |= CAN_CTRLMODE_TDC_AUTO |
CAN_CTRLMODE_TDC_MANUAL;
} else {
- fprintf(stderr,
- "Error: argument of \"tdc-mode\" must be \"auto\", \"manual\" or \"off\", not \"%s\"\n",
+ invarg("\"tdc-mode\" must be either of \"auto\", \"manual\" or \"off\"",
*argv);
- exit (-1);
}
} else if (matches(*argv, "restart") == 0) {
__u32 val = 1;
--
2.45.2