]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iplink_can: reduce the visibility of tdc in can_parse_opt()
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>
Tue, 12 Nov 2024 17:27:52 +0000 (02:27 +0900)
committerDavid Ahern <dsahern@kernel.org>
Mon, 18 Nov 2024 16:50:05 +0000 (16:50 +0000)
tdc is only used in a single if block. Move its declaration to the top
of the compound statement where it is used.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/iplink_can.c

index 01d977faa0ab3a91ee0c328eda4823dc8464add9..3414d6c398965b9083a861430da0e7ca8d756a51 100644 (file)
@@ -128,7 +128,6 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,
 {
        struct can_bittiming bt = {}, dbt = {};
        struct can_ctrlmode cm = { 0 };
-       struct rtattr *tdc;
        __u32 tdcv = -1, tdco = -1, tdcf = -1;
 
        while (argc > 0) {
@@ -298,7 +297,9 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,
                addattr_l(n, 1024, IFLA_CAN_CTRLMODE, &cm, sizeof(cm));
 
        if (tdcv != -1 || tdco != -1 || tdcf != -1) {
-               tdc = addattr_nest(n, 1024, IFLA_CAN_TDC | NLA_F_NESTED);
+               struct rtattr *tdc = addattr_nest(n, 1024,
+                                                 IFLA_CAN_TDC | NLA_F_NESTED);
+
                if (tdcv != -1)
                        addattr32(n, 1024, IFLA_CAN_TDC_TDCV, tdcv);
                if (tdco != -1)