Skip to content

Commit 5953763

Browse files
committed
lint(gps,tests): fix strict preflight regressions in unpushed NXDN/DMR changes
1 parent a6f4812 commit 5953763

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

src/core/gps/dsd_gps.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,14 +1053,14 @@ nxdn_gps_report(dsd_opts* opts, dsd_state* state, uint8_t* input, uint32_t src)
10531053
uint16_t lon_frac = (uint16_t)convert_bits_into_output(input + 16, 15);
10541054
uint8_t lon_hem = (uint8_t)convert_bits_into_output(input + 183, 1);
10551055
double lon_minutes = (double)(lon_degmin % 100U) + ((double)lon_frac / 10000.0);
1056-
double lon_decimal = (double)(lon_degmin / 100U) + (lon_minutes / 60.0);
1056+
double lon_decimal = ((double)lon_degmin / 100.0) + (lon_minutes / 60.0);
10571057
double longitude = (lon_hem == 0U) ? lon_decimal : -lon_decimal;
10581058

10591059
uint16_t lat_degmin = (uint16_t)convert_bits_into_output(input + 184, 16);
10601060
uint16_t lat_frac = (uint16_t)convert_bits_into_output(input + 200, 15);
10611061
uint8_t lat_hem = (uint8_t)convert_bits_into_output(input + 215, 1);
10621062
double lat_minutes = (double)(lat_degmin % 100U) + ((double)lat_frac / 10000.0);
1063-
double lat_decimal = (double)(lat_degmin / 100U) + (lat_minutes / 60.0);
1063+
double lat_decimal = ((double)lat_degmin / 100.0) + (lat_minutes / 60.0);
10641064
double latitude = (lat_hem == 0U) ? lat_decimal : -lat_decimal;
10651065

10661066
if (fabs(latitude) > 90.0 || fabs(longitude) > 180.0) {

tests/protocol/dmr/test_dmr_embedded_gps_position_error.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,19 @@ main(void) {
218218
nmea_ascii_to_bits(bits, (int)sizeof(bits), nmea_ok);
219219
st.dmr_lrrp_source[0] = 111U;
220220
st.dmr_lrrp_target[0] = 222U;
221-
memset(st.event_history_s[0].Event_History_Items[0].text_message, 0,
222-
sizeof(st.event_history_s[0].Event_History_Items[0].text_message));
221+
if (st.event_history_s != NULL) {
222+
memset(st.event_history_s[0].Event_History_Items[0].text_message, 0,
223+
sizeof(st.event_history_s[0].Event_History_Items[0].text_message));
224+
}
223225
uint8_t ok = nmea_sentence_checker(&opts, &st, bits, 0, len_bytes);
224226
rc |= expect_u8("nmea-valid", ok, 1U);
225-
rc |= expect_has_substr(st.event_history_s[0].Event_History_Items[0].text_message, "$GPRMC,TEST*71",
226-
"nmea-valid-text");
227+
if (st.event_history_s != NULL) {
228+
rc |= expect_has_substr(st.event_history_s[0].Event_History_Items[0].text_message, "$GPRMC,TEST*71",
229+
"nmea-valid-text");
230+
} else {
231+
fprintf(stderr, "%s\n", "nmea-valid-text: event_history_s is NULL");
232+
rc |= 1;
233+
}
227234
rc |= expect_u32("nmea-valid-src-reset", st.dmr_lrrp_source[0], 0U);
228235
rc |= expect_u32("nmea-valid-tgt-reset", st.dmr_lrrp_target[0], 0U);
229236
}
@@ -236,11 +243,18 @@ main(void) {
236243
nmea_ascii_to_bits(bits, (int)sizeof(bits), nmea_bad);
237244
st.dmr_lrrp_source[0] = 333U;
238245
st.dmr_lrrp_target[0] = 444U;
239-
memset(st.event_history_s[0].Event_History_Items[0].text_message, 0,
240-
sizeof(st.event_history_s[0].Event_History_Items[0].text_message));
246+
if (st.event_history_s != NULL) {
247+
memset(st.event_history_s[0].Event_History_Items[0].text_message, 0,
248+
sizeof(st.event_history_s[0].Event_History_Items[0].text_message));
249+
}
241250
uint8_t ok = nmea_sentence_checker(&opts, &st, bits, 0, len_bytes);
242251
rc |= expect_u8("nmea-invalid", ok, 0U);
243-
rc |= expect_i("nmea-invalid-text-empty", st.event_history_s[0].Event_History_Items[0].text_message[0], 0);
252+
if (st.event_history_s != NULL) {
253+
rc |= expect_i("nmea-invalid-text-empty", st.event_history_s[0].Event_History_Items[0].text_message[0], 0);
254+
} else {
255+
fprintf(stderr, "%s\n", "nmea-invalid-text-empty: event_history_s is NULL");
256+
rc |= 1;
257+
}
244258
rc |= expect_u32("nmea-invalid-src-reset", st.dmr_lrrp_source[0], 0U);
245259
rc |= expect_u32("nmea-invalid-tgt-reset", st.dmr_lrrp_target[0], 0U);
246260
}

tests/protocol/nxdn/test_nxdn_element_bounds.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#include <stdio.h>
1515
#include <string.h>
1616

17+
#include "dsd-neo/core/opts_fwd.h"
18+
#include "dsd-neo/core/state_fwd.h"
19+
1720
void NXDN_Elements_Content_decode(dsd_opts* opts, dsd_state* state, uint8_t CrcCorrect, uint8_t* ElementsContent,
1821
size_t elements_bits);
1922

0 commit comments

Comments
 (0)