Skip to content

Commit

Permalink
tests: canbus: rename shadow variables
Browse files Browse the repository at this point in the history
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
  • Loading branch information
dcpleung authored and carlescufi committed Aug 22, 2023
1 parent dc0cec9 commit 505c17e
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions tests/subsys/canbus/isotp/conformance/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const struct isotp_msg_id tx_addr_fixed = {
};

const struct device *const can_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus));
struct isotp_recv_ctx recv_ctx;
struct isotp_recv_ctx conform_recv_ctx;
struct isotp_send_ctx send_ctx;
uint8_t data_buf[128];
CAN_MSGQ_DEFINE(frame_msgq, 10);
Expand Down Expand Up @@ -354,13 +354,13 @@ ZTEST(isotp_conformance, test_receive_sf)
memcpy(&single_frame.data[1], random_data, DATA_SIZE_SF);
single_frame.length = DATA_SIZE_SF + 1;

ret = isotp_bind(&recv_ctx, can_dev, &rx_addr, &tx_addr,
ret = isotp_bind(&conform_recv_ctx, can_dev, &rx_addr, &tx_addr,
&fc_opts_single, K_NO_WAIT);
zassert_equal(ret, ISOTP_N_OK, "Binding failed [%d]", ret);

send_frame_series(&single_frame, 1, rx_addr.std_id);

get_sf(&recv_ctx, DATA_SIZE_SF);
get_sf(&conform_recv_ctx, DATA_SIZE_SF);

single_frame.data[0] = SF_PCI_BYTE_LEN_8;
send_frame_series(&single_frame, 1, rx_addr.std_id);
Expand All @@ -370,10 +370,10 @@ ZTEST(isotp_conformance, test_receive_sf)
single_frame.length = 7;
send_frame_series(&single_frame, 1, rx_addr.std_id);

get_sf_ignore(&recv_ctx);
get_sf_ignore(&conform_recv_ctx);
#endif

isotp_unbind(&recv_ctx);
isotp_unbind(&conform_recv_ctx);
}

ZTEST(isotp_conformance, test_send_sf_ext)
Expand Down Expand Up @@ -410,13 +410,13 @@ ZTEST(isotp_conformance, test_receive_sf_ext)
memcpy(&single_frame.data[2], random_data, DATA_SIZE_SF_EXT);
single_frame.length = DATA_SIZE_SF_EXT + 2;

ret = isotp_bind(&recv_ctx, can_dev, &rx_addr_ext, &tx_addr,
ret = isotp_bind(&conform_recv_ctx, can_dev, &rx_addr_ext, &tx_addr,
&fc_opts_single, K_NO_WAIT);
zassert_equal(ret, ISOTP_N_OK, "Binding failed [%d]", ret);

send_frame_series(&single_frame, 1, rx_addr.std_id);

get_sf(&recv_ctx, DATA_SIZE_SF_EXT);
get_sf(&conform_recv_ctx, DATA_SIZE_SF_EXT);

single_frame.data[1] = SF_PCI_BYTE_1;
send_frame_series(&single_frame, 1, rx_addr.std_id);
Expand All @@ -426,10 +426,10 @@ ZTEST(isotp_conformance, test_receive_sf_ext)
single_frame.length = 7;
send_frame_series(&single_frame, 1, rx_addr.std_id);

get_sf_ignore(&recv_ctx);
get_sf_ignore(&conform_recv_ctx);
#endif

isotp_unbind(&recv_ctx);
isotp_unbind(&conform_recv_ctx);
}

ZTEST(isotp_conformance, test_send_sf_fixed)
Expand Down Expand Up @@ -465,27 +465,27 @@ ZTEST(isotp_conformance, test_receive_sf_fixed)
memcpy(&single_frame.data[1], random_data, DATA_SIZE_SF);
single_frame.length = DATA_SIZE_SF + 1;

ret = isotp_bind(&recv_ctx, can_dev, &rx_addr_fixed, &tx_addr_fixed,
ret = isotp_bind(&conform_recv_ctx, can_dev, &rx_addr_fixed, &tx_addr_fixed,
&fc_opts_single, K_NO_WAIT);
zassert_equal(ret, ISOTP_N_OK, "Binding failed [%d]", ret);

/* default source address */
send_frame_series(&single_frame, 1, rx_addr_fixed.ext_id);
get_sf(&recv_ctx, DATA_SIZE_SF);
get_sf(&conform_recv_ctx, DATA_SIZE_SF);

/* different source address */
send_frame_series(&single_frame, 1, rx_addr_fixed.ext_id | 0xFF);
get_sf(&recv_ctx, DATA_SIZE_SF);
get_sf(&conform_recv_ctx, DATA_SIZE_SF);

/* different priority */
send_frame_series(&single_frame, 1, rx_addr_fixed.ext_id | (7U << 26));
get_sf(&recv_ctx, DATA_SIZE_SF);
get_sf(&conform_recv_ctx, DATA_SIZE_SF);

/* different target address (should fail) */
send_frame_series(&single_frame, 1, rx_addr_fixed.ext_id | 0xFF00);
get_sf_ignore(&recv_ctx);
get_sf_ignore(&conform_recv_ctx);

isotp_unbind(&recv_ctx);
isotp_unbind(&conform_recv_ctx);
}

ZTEST(isotp_conformance, test_send_data)
Expand Down Expand Up @@ -606,7 +606,7 @@ ZTEST(isotp_conformance, test_receive_data)

filter_id = add_rx_msgq(tx_addr.std_id, CAN_STD_ID_MASK);

ret = isotp_bind(&recv_ctx, can_dev, &rx_addr, &tx_addr,
ret = isotp_bind(&conform_recv_ctx, can_dev, &rx_addr, &tx_addr,
&fc_opts_single, K_NO_WAIT);
zassert_equal(ret, ISOTP_N_OK, "Binding failed [%d]", ret);

Expand All @@ -616,10 +616,10 @@ ZTEST(isotp_conformance, test_receive_data)

send_frame_series(des_frames, ARRAY_SIZE(des_frames), rx_addr.std_id);

receive_test_data(&recv_ctx, random_data, DATA_SEND_LENGTH, 0);
receive_test_data(&conform_recv_ctx, random_data, DATA_SEND_LENGTH, 0);

can_remove_rx_filter(can_dev, filter_id);
isotp_unbind(&recv_ctx);
isotp_unbind(&conform_recv_ctx);
}

ZTEST(isotp_conformance, test_receive_data_blocks)
Expand Down Expand Up @@ -651,7 +651,7 @@ ZTEST(isotp_conformance, test_receive_data_blocks)
zassert_true((filter_id >= 0), "Negative filter number [%d]",
filter_id);

ret = isotp_bind(&recv_ctx, can_dev, &rx_addr, &tx_addr,
ret = isotp_bind(&conform_recv_ctx, can_dev, &rx_addr, &tx_addr,
&fc_opts, K_NO_WAIT);
zassert_equal(ret, ISOTP_N_OK, "Binding failed [%d]", ret);

Expand All @@ -676,10 +676,10 @@ ZTEST(isotp_conformance, test_receive_data_blocks)
ret = k_msgq_get(&frame_msgq, &dummy_frame, K_MSEC(50));
zassert_equal(ret, -EAGAIN, "Expected timeout but got %d", ret);

receive_test_data(&recv_ctx, random_data, DATA_SEND_LENGTH, 0);
receive_test_data(&conform_recv_ctx, random_data, DATA_SEND_LENGTH, 0);

can_remove_rx_filter(can_dev, filter_id);
isotp_unbind(&recv_ctx);
isotp_unbind(&conform_recv_ctx);
}

ZTEST(isotp_conformance, test_send_timeouts)
Expand Down Expand Up @@ -751,17 +751,17 @@ ZTEST(isotp_conformance, test_receive_timeouts)
memcpy(&ff_frame.data[2], random_data, DATA_SIZE_FF);
ff_frame.length = DATA_SIZE_FF + 2;

ret = isotp_bind(&recv_ctx, can_dev, &rx_addr, &tx_addr,
ret = isotp_bind(&conform_recv_ctx, can_dev, &rx_addr, &tx_addr,
&fc_opts, K_NO_WAIT);
zassert_equal(ret, ISOTP_N_OK, "Binding failed [%d]", ret);

send_frame_series(&ff_frame, 1, rx_addr.std_id);
start_time = k_uptime_get_32();

ret = isotp_recv(&recv_ctx, data_buf, sizeof(data_buf), K_FOREVER);
ret = isotp_recv(&conform_recv_ctx, data_buf, sizeof(data_buf), K_FOREVER);
zassert_equal(ret, DATA_SIZE_FF,
"Expected FF data length but got %d", ret);
ret = isotp_recv(&recv_ctx, data_buf, sizeof(data_buf), K_FOREVER);
ret = isotp_recv(&conform_recv_ctx, data_buf, sizeof(data_buf), K_FOREVER);
zassert_equal(ret, ISOTP_N_TIMEOUT_CR,
"Expected timeout but got %d", ret);

Expand All @@ -771,7 +771,7 @@ ZTEST(isotp_conformance, test_receive_timeouts)
zassert_true(time_diff <= BS_TIMEOUT_UPPER_MS,
"Timeout too slow (%dms)", time_diff);

isotp_unbind(&recv_ctx);
isotp_unbind(&conform_recv_ctx);
}

ZTEST(isotp_conformance, test_stmin)
Expand Down Expand Up @@ -852,7 +852,7 @@ ZTEST(isotp_conformance, test_receiver_fc_errors)
zassert_true((filter_id >= 0), "Negative filter number [%d]",
filter_id);

ret = isotp_bind(&recv_ctx, can_dev, &rx_addr, &tx_addr,
ret = isotp_bind(&conform_recv_ctx, can_dev, &rx_addr, &tx_addr,
&fc_opts, K_NO_WAIT);
zassert_equal(ret, ISOTP_N_OK, "Binding failed [%d]", ret);

Expand All @@ -866,10 +866,10 @@ ZTEST(isotp_conformance, test_receiver_fc_errors)
des_frames[1].data[0] = CF_PCI_BYTE_1 | (3 & 0x0F);
send_frame_series(des_frames, fc_opts.bs, rx_addr.std_id);

ret = isotp_recv(&recv_ctx, data_buf, sizeof(data_buf), K_MSEC(200));
ret = isotp_recv(&conform_recv_ctx, data_buf, sizeof(data_buf), K_MSEC(200));
zassert_equal(ret, DATA_SIZE_FF,
"Expected FF data length but got %d", ret);
ret = isotp_recv(&recv_ctx, data_buf, sizeof(data_buf), K_MSEC(200));
ret = isotp_recv(&conform_recv_ctx, data_buf, sizeof(data_buf), K_MSEC(200));
zassert_equal(ret, ISOTP_N_WRONG_SN,
"Expected wrong SN but got %d", ret);

Expand All @@ -881,8 +881,8 @@ ZTEST(isotp_conformance, test_receiver_fc_errors)
fc_frame.data[1] = FC_PCI_BYTE_2(0);
fc_frame.data[2] = FC_PCI_BYTE_3(0);

isotp_unbind(&recv_ctx);
ret = isotp_bind(&recv_ctx, can_dev, &rx_addr, &tx_addr,
isotp_unbind(&conform_recv_ctx);
ret = isotp_bind(&conform_recv_ctx, can_dev, &rx_addr, &tx_addr,
&fc_opts_single, K_NO_WAIT);
zassert_equal(ret, ISOTP_N_OK, "Binding failed [%d]", ret);

Expand All @@ -891,7 +891,7 @@ ZTEST(isotp_conformance, test_receiver_fc_errors)

can_remove_rx_filter(can_dev, filter_id);
k_msgq_cleanup(&frame_msgq);
isotp_unbind(&recv_ctx);
isotp_unbind(&conform_recv_ctx);
}

ZTEST(isotp_conformance, test_sender_fc_errors)
Expand Down

0 comments on commit 505c17e

Please sign in to comment.