Thread (10 messages) 10 messages, 4 authors, 2025-09-25
STALE276d

[PATCH iproute2-next 3/3] iplink_can: factorise the calls to usage()

From: Vincent Mailhol <mailhol@kernel.org>
Date: 2025-09-21 07:33:12
Also in: linux-can, lkml
Subsystem: the rest · Maintainer: Linus Torvalds

usage() is called either if the user passes the "help" argument or passes
an invalid argument.

Factorise those two cases together.

This silences below checkpatch.pl warning:

  WARNING: else is not generally useful after a break or return
  #274: FILE: ip/iplink_can.c:274:
  +			return -1;
  +		} else {

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
 ip/iplink_can.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/ip/iplink_can.c b/ip/iplink_can.c
index 56c258b023ef57e37574f44981b76086a0a140db..2a13df7bcf6d404e17cf747f29c682fa80e4f6fc 100644
--- a/ip/iplink_can.c
+++ b/ip/iplink_can.c
@@ -268,11 +268,9 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,
 				invarg("invalid \"termination\" value",
 				       *argv);
 			addattr16(n, 1024, IFLA_CAN_TERMINATION, val);
-		} else if (matches(*argv, "help") == 0) {
-			usage();
-			return -1;
 		} else {
-			fprintf(stderr, "can: unknown option \"%s\"\n", *argv);
+			if (matches(*argv, "help") != 0)
+				fprintf(stderr, "can: unknown option \"%s\"\n", *argv);
 			usage();
 			return -1;
 		}
-- 
2.49.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help