]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/iplink_can.c
iproute: make clang happy
[mirror_iproute2.git] / ip / iplink_can.c
index f415558a9b3962823050cc65f627506c56944a9f..c0deeb1f1fcf38e466ce38d8c1ebebab399db669 100644 (file)
@@ -251,7 +251,7 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,
        return 0;
 }
 
-static const char *can_state_names[] = {
+static const char *can_state_names[CAN_STATE_MAX] = {
        [CAN_STATE_ERROR_ACTIVE] = "ERROR-ACTIVE",
        [CAN_STATE_ERROR_WARNING] = "ERROR-WARNING",
        [CAN_STATE_ERROR_PASSIVE] = "ERROR-PASSIVE",
@@ -283,11 +283,8 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
        if (tb[IFLA_CAN_STATE]) {
                uint32_t state = rta_getattr_u32(tb[IFLA_CAN_STATE]);
 
-               if (state <= CAN_STATE_MAX)
-                       print_string(PRINT_ANY, "state", "state %s ",
-                                    can_state_names[state]);
-               else
-                       print_null(PRINT_ANY, "state", "state UNKNOWN", NULL);
+               fprintf(f, "state %s ", state < CAN_STATE_MAX ?
+                       can_state_names[state] : "UNKNOWN");
        }
 
        if (tb[IFLA_CAN_BERR_COUNTER]) {
@@ -319,11 +316,14 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                struct can_bittiming *bt = RTA_DATA(tb[IFLA_CAN_BITTIMING]);
 
                if (is_json_context()) {
+                       json_writer_t *jw;
+
                        open_json_object("bittiming");
                        print_int(PRINT_ANY, "bitrate", NULL, bt->bitrate);
-                       jsonw_float_field_fmt(get_json_writer(),
-                                             "sample_point", "%.3f",
-                                             (float) bt->sample_point / 1000.);
+                       jw = get_json_writer();
+                       jsonw_name(jw, "sample_point");
+                       jsonw_printf(jw, "%.3f",
+                                    (float) bt->sample_point / 1000);
                        print_int(PRINT_ANY, "tq", NULL, bt->tq);
                        print_int(PRINT_ANY, "prop_seg", NULL, bt->prop_seg);
                        print_int(PRINT_ANY, "phase_seg1",
@@ -418,12 +418,14 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                        RTA_DATA(tb[IFLA_CAN_DATA_BITTIMING]);
 
                if (is_json_context()) {
+                       json_writer_t *jw;
+
                        open_json_object("data_bittiming");
                        print_int(PRINT_JSON, "bitrate", NULL, dbt->bitrate);
-                       jsonw_float_field_fmt(get_json_writer(),
-                                             "sample_point",
-                                             "%.3f",
-                                             (float) dbt->sample_point / 1000.);
+                       jw = get_json_writer();
+                       jsonw_name(jw, "sample_point");
+                       jsonw_printf(jw, "%.3f",
+                                    (float) dbt->sample_point / 1000.);
                        print_int(PRINT_JSON, "tq", NULL, dbt->tq);
                        print_int(PRINT_JSON, "prop_seg", NULL, dbt->prop_seg);
                        print_int(PRINT_JSON, "phase_seg1",