Skip to content

Commit 9cab65c

Browse files
committed
Replace asserts with internal error messages.
1 parent d8913f0 commit 9cab65c

File tree

1 file changed

+37
-17
lines changed

1 file changed

+37
-17
lines changed

Diff for: telemetry.c

+37-17
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ static struct t_metadata_s * t_get_metadata (char *station)
143143
for (p = md_list_head; p != NULL; p = p->pnext) {
144144
if (strcmp(station, p->station) == 0) {
145145

146-
assert (p->magic1 == MAGIC1);
147-
assert (p->magic2 == MAGIC2);
148-
146+
if (p->magic1 != MAGIC1 || p->magic2 != MAGIC2) {
147+
text_color_set(DW_COLOR_ERROR);
148+
dw_printf("Internal error: REPORT THIS! Bad magic values %s %d\n", __func__, __LINE__);
149+
}
149150
return (p);
150151
}
151152
}
@@ -285,8 +286,10 @@ void telemetry_data_original (char *station, char *info, int quiet, char *output
285286

286287
pm = t_get_metadata(station);
287288

288-
assert (pm->magic1 == MAGIC1);
289-
assert (pm->magic2 == MAGIC2);
289+
if (pm->magic1 != MAGIC1 || pm->magic2 != MAGIC2) {
290+
text_color_set(DW_COLOR_ERROR);
291+
dw_printf("Internal error: REPORT THIS! Bad magic values %s %d\n", __func__, __LINE__);
292+
}
290293

291294
seq = 0;
292295
for (n = 0; n < T_NUM_ANALOG; n++) {
@@ -482,8 +485,10 @@ void telemetry_data_base91 (char *station, char *cdata, char *output, size_t out
482485

483486
pm = t_get_metadata(station);
484487

485-
assert (pm->magic1 == MAGIC1);
486-
assert (pm->magic2 == MAGIC2);
488+
if (pm->magic1 != MAGIC1 || pm->magic2 != MAGIC2) {
489+
text_color_set(DW_COLOR_ERROR);
490+
dw_printf("Internal error: REPORT THIS! Bad magic values %s %d\n", __func__, __LINE__);
491+
}
487492

488493
seq = 0;
489494
for (n = 0; n < T_NUM_ANALOG; n++) {
@@ -588,8 +593,11 @@ void telemetry_name_message (char *station, char *msg)
588593
}
589594

590595
pm = t_get_metadata(station);
591-
assert (pm->magic1 == MAGIC1);
592-
assert (pm->magic2 == MAGIC2);
596+
597+
if (pm->magic1 != MAGIC1 || pm->magic2 != MAGIC2) {
598+
text_color_set(DW_COLOR_ERROR);
599+
dw_printf("Internal error: REPORT THIS! Bad magic values %s %d\n", __func__, __LINE__);
600+
}
593601

594602
next = stemp;
595603

@@ -664,8 +672,11 @@ void telemetry_unit_label_message (char *station, char *msg)
664672
}
665673

666674
pm = t_get_metadata(station);
667-
assert (pm->magic1 == MAGIC1);
668-
assert (pm->magic2 == MAGIC2);
675+
676+
if (pm->magic1 != MAGIC1 || pm->magic2 != MAGIC2) {
677+
text_color_set(DW_COLOR_ERROR);
678+
dw_printf("Internal error: REPORT THIS! Bad magic values %s %d\n", __func__, __LINE__);
679+
}
669680

670681
next = stemp;
671682

@@ -741,8 +752,11 @@ void telemetry_coefficents_message (char *station, char *msg, int quiet)
741752
}
742753

743754
pm = t_get_metadata(station);
744-
assert (pm->magic1 == MAGIC1);
745-
assert (pm->magic2 == MAGIC2);
755+
756+
if (pm->magic1 != MAGIC1 || pm->magic2 != MAGIC2) {
757+
text_color_set(DW_COLOR_ERROR);
758+
dw_printf("Internal error: REPORT THIS! Bad magic values %s %d\n", __func__, __LINE__);
759+
}
746760

747761
next = stemp;
748762

@@ -821,8 +835,11 @@ void telemetry_bit_sense_message (char *station, char *msg, int quiet)
821835
#endif
822836

823837
pm = t_get_metadata(station);
824-
assert (pm->magic1 == MAGIC1);
825-
assert (pm->magic2 == MAGIC2);
838+
839+
if (pm->magic1 != MAGIC1 || pm->magic2 != MAGIC2) {
840+
text_color_set(DW_COLOR_ERROR);
841+
dw_printf("Internal error: REPORT THIS! Bad magic values %s %d\n", __func__, __LINE__);
842+
}
826843

827844
if (strlen(msg) < 8) {
828845
if ( ! quiet) {
@@ -931,8 +948,11 @@ static void t_data_process (struct t_metadata_s *pm, int seq, float araw[T_NUM_A
931948

932949

933950
assert (pm != NULL);
934-
assert (pm->magic1 == MAGIC1);
935-
assert (pm->magic2 == MAGIC2);
951+
952+
if (pm->magic1 != MAGIC1 || pm->magic2 != MAGIC2) {
953+
text_color_set(DW_COLOR_ERROR);
954+
dw_printf("Internal error: REPORT THIS! Bad magic values %s %d\n", __func__, __LINE__);
955+
}
936956

937957
strlcpy (output, "", outputsize);
938958

0 commit comments

Comments
 (0)