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

Vincent Mailhol posted 3 patches 1 week, 3 days ago
[PATCH iproute2-next 3/3] iplink_can: factorise the calls to usage()
Posted by Vincent Mailhol 1 week, 3 days ago
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
Re: [PATCH iproute2-next 3/3] iplink_can: factorise the calls to usage()
Posted by Stephen Hemminger 1 week, 2 days ago
On Sun, 21 Sep 2025 16:32:32 +0900
Vincent Mailhol <mailhol@kernel.org> wrote:

> 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>
> ---

Not accepting most checkpatch stuff in iproute2.
Better to not have code churn