Skip to content

Commit 368db38

Browse files
jhirsirlubos
authored andcommitted
samples: dect_phy: dect_shell: ping/perf: coverity issues fixed
Changes due to Coverity report. Signed-off-by: Jani Hirsimäki <[email protected]>
1 parent 6a917da commit 368db38

File tree

7 files changed

+39
-12
lines changed

7 files changed

+39
-12
lines changed

samples/dect/dect_phy/dect_shell/src/dect/perf/dect_phy_perf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ static void dect_phy_perf_rx_pcc_cb(uint64_t const *time,
465465

466466
ctrl_pcc_op_params.pcc_status = *p_rx_status;
467467
ctrl_pcc_op_params.phy_header = *p_phy_header;
468+
ctrl_pcc_op_params.phy_len = header->packet_length;
469+
ctrl_pcc_op_params.phy_len_type = header->packet_length_type;
468470
ctrl_pcc_op_params.time = *time;
469471
ctrl_pcc_op_params.stf_start_time = p_rx_status->stf_start_time;
470472

@@ -596,6 +598,7 @@ static void dect_phy_perf_rx_pdc_cb(uint64_t const *time,
596598

597599
perf_pdc_op_params.rx_pwr_dbm = 0; /* Not needed from PDC */
598600
perf_pdc_op_params.rx_rssi_level_dbm = rssi_level;
601+
perf_pdc_op_params.last_rx_op_channel = perf_data.cmd_params.channel;
599602

600603
if (length <= sizeof(perf_pdc_op_params.data)) {
601604
memcpy(perf_pdc_op_params.data, p_data, length);
@@ -1062,6 +1065,7 @@ static int dect_phy_perf_tx_request_results(void)
10621065
memcpy(&phy_header.type_2, &header, sizeof(phy_header.type_2));
10631066

10641067
perf_pdu.header.message_type = DECT_MAC_MESSAGE_TYPE_PERF_RESULTS_REQ;
1068+
perf_pdu.message.results_req.unused = 0;
10651069
perf_pdu.header.transmitter_id = current_settings->common.transmitter_id;
10661070
dect_phy_perf_pdu_encode(encoded_data_to_send, &perf_pdu);
10671071

samples/dect/dect_phy/dect_shell/src/dect/perf/dect_phy_perf_pdu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ uint8_t *dect_phy_perf_pdu_encode(uint8_t *p_target, const dect_phy_perf_pdu_t *
4242
p_target = p_target + sizeof(p_input->message.tx_data.pdu_payload);
4343
} else if (p_input->header.message_type == DECT_MAC_MESSAGE_TYPE_PERF_RESULTS_REQ) {
4444
p_target = dect_common_utils_32bit_be_write(p_target,
45-
p_input->message.results_req.foo);
45+
p_input->message.results_req.unused);
4646
} else if (p_input->header.message_type == DECT_MAC_MESSAGE_TYPE_PERF_RESULTS_RESP) {
4747
strncpy(p_target, p_input->message.results.results_str,
48-
DECT_PHY_PERF_RESULTS_DATA_MAX_LEN);
48+
DECT_PHY_PERF_RESULTS_DATA_MAX_LEN - 1);
4949
}
5050

5151
return p_target;
@@ -66,7 +66,7 @@ int dect_phy_perf_pdu_decode(dect_phy_perf_pdu_t *p_target, const uint8_t *p_dat
6666
p_target->message.tx_data.payload_length);
6767
} else if (p_target->header.message_type == DECT_MAC_MESSAGE_TYPE_PERF_RESULTS_RESP) {
6868
strncpy(p_target->message.results.results_str, p_ptr,
69-
DECT_PHY_PERF_RESULTS_DATA_MAX_LEN);
69+
DECT_PHY_PERF_RESULTS_DATA_MAX_LEN - 1);
7070
}
7171

7272
return 0;

samples/dect/dect_phy/dect_shell/src/dect/perf/dect_phy_perf_pdu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct {
3434
char results_str[DECT_PHY_PERF_RESULTS_DATA_MAX_LEN];
3535
} dect_phy_perf_pdu_results_resp_data;
3636
typedef struct {
37-
uint32_t foo;
37+
uint32_t unused;
3838
} dect_phy_perf_pdu_results_req;
3939

4040
typedef struct {
@@ -44,7 +44,7 @@ typedef struct {
4444
} dect_phy_perf_pdu_tx_data;
4545

4646
typedef struct {
47-
uint8_t foo_fighters;
47+
uint8_t unused;
4848
} dect_phy_perf_pdu_harq_feedback_t;
4949

5050
typedef union {

samples/dect/dect_phy/dect_shell/src/dect/ping/dect_phy_ping.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ static void dect_phy_ping_rx_pcc_cb(uint64_t const *time,
543543
ctrl_pcc_op_params.pcc_status = *p_rx_status;
544544
ctrl_pcc_op_params.phy_header = *p_phy_header;
545545
ctrl_pcc_op_params.time = *time;
546+
ctrl_pcc_op_params.stf_start_time = p_rx_status->stf_start_time;
547+
/* Others from struct dect_phy_common_op_pcc_rcv_params are not needed */
546548

547549
/* Provide HARQ feedback if requested */
548550
if (p_rx_status->header_status == NRF_MODEM_DECT_PHY_HDR_STATUS_VALID &&
@@ -626,7 +628,7 @@ static void dect_phy_ping_rx_pdc_cb(uint64_t const *time,
626628

627629
dect_app_modem_time_save(time);
628630

629-
struct dect_phy_commmon_op_pdc_rcv_params ping_pdc_op_params;
631+
struct dect_phy_commmon_op_pdc_rcv_params ping_pdc_op_params = { 0 };
630632

631633
ping_pdc_op_params.rx_status = *p_rx_status;
632634

@@ -637,6 +639,9 @@ static void dect_phy_ping_rx_pdc_cb(uint64_t const *time,
637639
dect_common_utils_phy_tx_power_to_dbm(ping_data.rx_metrics.rx_phy_transmit_pwr);
638640
ping_pdc_op_params.rx_mcs = ping_data.rx_metrics.rx_last_pcc_mcs;
639641
ping_pdc_op_params.rx_rssi_level_dbm = rssi_level;
642+
ping_pdc_op_params.last_rx_op_channel = ping_data.cmd_params.channel;
643+
644+
/* Others from struct dect_phy_commmon_op_pdc_rcv_params are not needed */
640645

641646
if (length <= sizeof(ping_pdc_op_params.data)) {
642647
memcpy(ping_pdc_op_params.data, p_data, length);
@@ -1018,6 +1023,9 @@ static int dect_phy_ping_client_start(void)
10181023
ping_data.client_data.tx_op.data_size = ping_pdu_byte_count;
10191024
ping_data.client_data.tx_op.data = encoded_data_to_send;
10201025
ping_data.client_data.tx_op.lbt_period = 0;
1026+
ping_data.client_data.tx_op.lbt_rssi_threshold_max =
1027+
current_settings->rssi_scan.busy_threshold;
1028+
10211029
ping_data.client_data.tx_op.network_id = current_settings->common.network_id;
10221030
ping_data.client_data.tx_op.phy_header = &ping_data.client_data.tx_phy_header;
10231031
ping_data.client_data.tx_op.phy_type = DECT_PHY_HEADER_TYPE2;
@@ -1146,13 +1154,15 @@ static int dect_phy_ping_tx_request_results(void)
11461154
ping_pdu.header.transmitter_id = current_settings->common.transmitter_id;
11471155
ping_pdu.header.pwr_ctrl_expected_rssi_level_dbm =
11481156
params->pwr_ctrl_pdu_expected_rx_rssi_level;
1157+
ping_pdu.message.results_req.unused = 0;
11491158
dect_phy_ping_pdu_encode(encoded_data_to_send, &ping_pdu);
11501159

11511160
tx_op.bs_cqi = NRF_MODEM_DECT_PHY_BS_CQI_NOT_USED;
11521161
tx_op.carrier = params->channel;
11531162
tx_op.data_size = DECT_PHY_PING_RESULTS_REQ_LEN;
11541163
tx_op.data = encoded_data_to_send;
11551164
tx_op.lbt_period = 0;
1165+
tx_op.lbt_rssi_threshold_max = current_settings->rssi_scan.busy_threshold;
11561166
tx_op.network_id = current_settings->common.network_id;
11571167
tx_op.phy_header = &phy_header;
11581168
tx_op.phy_type = DECT_PHY_HEADER_TYPE2;
@@ -1263,7 +1273,7 @@ dect_phy_ping_client_report_local_results_and_req_server_results(int64_t *elapse
12631273
ping_data.restarted_count = 0;
12641274
dect_phy_ping_rx_metrics_reset(params);
12651275

1266-
memset(&ping_data.tx_metrics, 0, sizeof(struct dect_phy_ping_rx_metrics));
1276+
memset(&ping_data.tx_metrics, 0, sizeof(struct dect_phy_ping_tx_metrics));
12671277

12681278
return ret;
12691279
}
@@ -1322,11 +1332,14 @@ static int dect_phy_ping_server_results_tx(char *result_str)
13221332
tx_op.data_size = bytes_to_send;
13231333
tx_op.data = encoded_data_to_send;
13241334
tx_op.lbt_period = 0;
1335+
tx_op.lbt_rssi_threshold_max = current_settings->rssi_scan.busy_threshold;
1336+
13251337
tx_op.network_id = current_settings->common.network_id;
13261338
tx_op.phy_header = &phy_header;
13271339
tx_op.phy_type = DECT_PHY_HEADER_TYPE2;
13281340
tx_op.handle = DECT_PHY_PING_RESULTS_RESP_TX_HANDLE;
13291341
tx_op.start_time = first_possible_tx;
1342+
13301343
tx_rx_param.tx = tx_op;
13311344
tx_rx_param.rx = ping_data.server_data.server_rx_op;
13321345

@@ -1414,6 +1427,8 @@ static int dect_phy_ping_server_ping_resp_tx(struct dect_phy_data_rcv_common_par
14141427
tx_op.data_size = bytes_to_send;
14151428
tx_op.data = encoded_data_to_send;
14161429
tx_op.lbt_period = 0;
1430+
tx_op.lbt_rssi_threshold_max = current_settings->rssi_scan.busy_threshold;
1431+
14171432
tx_op.network_id = current_settings->common.network_id;
14181433
tx_op.phy_header = &phy_header;
14191434
tx_op.phy_type = DECT_PHY_HEADER_TYPE2;

samples/dect/dect_phy/dect_shell/src/dect/ping/dect_phy_ping_pdu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ uint8_t *dect_phy_ping_pdu_encode(uint8_t *p_target, const dect_phy_ping_pdu_t *
4444
p_target = p_target + sizeof(p_input->message.tx_data.pdu_payload);
4545
} else if (p_input->header.message_type == DECT_MAC_MESSAGE_TYPE_PING_RESULTS_REQ) {
4646
p_target = dect_common_utils_32bit_be_write(p_target,
47-
p_input->message.results_req.foo);
47+
p_input->message.results_req.unused);
4848
} else if (p_input->header.message_type == DECT_MAC_MESSAGE_TYPE_PING_RESULTS_RESP) {
4949
strncpy(p_target, p_input->message.results.results_str,
50-
DECT_PHY_PING_RESULTS_DATA_MAX_LEN);
50+
DECT_PHY_PING_RESULTS_DATA_MAX_LEN - 1);
5151
}
5252

5353
return p_target;
@@ -69,7 +69,7 @@ int dect_phy_ping_pdu_decode(dect_phy_ping_pdu_t *p_target, const uint8_t *p_dat
6969
p_target->message.tx_data.payload_length);
7070
} else if (p_target->header.message_type == DECT_MAC_MESSAGE_TYPE_PING_RESULTS_RESP) {
7171
strncpy(p_target->message.results.results_str, p_ptr,
72-
DECT_PHY_PING_RESULTS_DATA_MAX_LEN);
72+
DECT_PHY_PING_RESULTS_DATA_MAX_LEN - 1);
7373
}
7474

7575
return 0;

samples/dect/dect_phy/dect_shell/src/dect/ping/dect_phy_ping_pdu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef struct {
3737
} dect_phy_ping_pdu_results_resp_data;
3838

3939
typedef struct {
40-
uint32_t foo;
40+
uint32_t unused;
4141
} dect_phy_ping_pdu_results_req;
4242

4343
typedef struct {

samples/dect/dect_phy/dect_shell/src/dect/rf_tool/dect_phy_rf_tool.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,16 @@ static void dect_phy_rf_tool_rx_pcc_cb(uint64_t const *time,
178178
union nrf_modem_dect_phy_hdr const *p_phy_header)
179179
{
180180
struct dect_phy_common_op_pcc_rcv_params ctrl_pcc_op_params;
181+
struct dect_phy_header_type2_format0_t *header = (void *)p_phy_header;
181182

182183
dect_app_modem_time_save(time);
183184

184185
ctrl_pcc_op_params.pcc_status = *p_rx_status;
185186
ctrl_pcc_op_params.phy_header = *p_phy_header;
186187
ctrl_pcc_op_params.time = *time;
187188
ctrl_pcc_op_params.stf_start_time = p_rx_status->stf_start_time;
189+
ctrl_pcc_op_params.phy_len = header->packet_length;
190+
ctrl_pcc_op_params.phy_len_type = header->packet_length_type;
188191

189192
dect_phy_rf_tool_msgq_data_op_add(DECT_PHY_RF_TOOL_EVT_RX_PCC,
190193
(void *)&ctrl_pcc_op_params,
@@ -222,6 +225,7 @@ static void dect_phy_rf_tool_rx_pdc_cb(uint64_t const *time,
222225

223226
rf_tool_pdc_op_params.rx_pwr_dbm = 0; /* Taken from PCC */
224227
rf_tool_pdc_op_params.rx_rssi_level_dbm = rssi_level; /* Used from PCC */
228+
rf_tool_pdc_op_params.last_rx_op_channel = rf_tool_data.cmd_params.channel;
225229

226230
if (length <= sizeof(rf_tool_pdc_op_params.data)) {
227231
memcpy(rf_tool_pdc_op_params.data, p_data, length);
@@ -1191,7 +1195,11 @@ static int dect_phy_rf_tool_start(struct dect_phy_rf_tool_params *params, bool r
11911195
dect_common_utils_subslots_in_bytes(len_subslots, params->tx_mcs);
11921196

11931197
if (len_bytes <= 0) {
1194-
desh_error("Unsupported slot/mcs combination");
1198+
desh_error("%s: Unsupported slot/mcs combination", __func__);
1199+
return -1;
1200+
}
1201+
if (len_bytes > DECT_DATA_MAX_LEN) {
1202+
desh_error("%s: Too long TX data: %d bytes", __func__, len_bytes);
11951203
return -1;
11961204
}
11971205

0 commit comments

Comments
 (0)