Skip to content

Commit 8151ad4

Browse files
committed
minor: fix use list in well_known_output_fields
1 parent dc25708 commit 8151ad4

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

src/r_api.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -328,35 +328,38 @@ char *time_pos_str(r_cfg_t *cfg, unsigned samples_ago, char *buf)
328328
// well-known field "protocol" is only used when model protocol is requested
329329
// well-known field "description" is only used when model description is requested
330330
// well-known fields "mod", "freq", "freq1", "freq2", "rssi", "snr", "noise" are used by meta report option
331-
static char const *well_known_default[15] = {0};
332331
char const **well_known_output_fields(r_cfg_t *cfg)
333332
{
334-
char const **p = well_known_default;
335-
*p++ = "time";
336-
*p++ = "msg";
337-
*p++ = "codes";
333+
list_t field_list = {0};
334+
list_ensure_size(&field_list, 15);
335+
336+
list_push(&field_list, "time");
337+
list_push(&field_list, "msg");
338+
list_push(&field_list, "codes");
338339

339340
if (cfg->verbose_bits)
340-
*p++ = "bits";
341+
list_push(&field_list, "bits");
342+
341343
for (void **iter = cfg->data_tags.elems; iter && *iter; ++iter) {
342344
data_tag_t *tag = *iter;
343-
*p++ = tag->key;
345+
list_push(&field_list, tag->key);
344346
}
347+
345348
if (cfg->report_protocol)
346-
*p++ = "protocol";
349+
list_push(&field_list, "protocol");
347350
if (cfg->report_description)
348-
*p++ = "description";
351+
list_push(&field_list, "description");
349352
if (cfg->report_meta) {
350-
*p++ = "mod";
351-
*p++ = "freq";
352-
*p++ = "freq1";
353-
*p++ = "freq2";
354-
*p++ = "rssi";
355-
*p++ = "snr";
356-
*p++ = "noise";
353+
list_push(&field_list, "mod");
354+
list_push(&field_list, "freq");
355+
list_push(&field_list, "freq1");
356+
list_push(&field_list, "freq2");
357+
list_push(&field_list, "rssi");
358+
list_push(&field_list, "snr");
359+
list_push(&field_list, "noise");
357360
}
358361

359-
return well_known_default;
362+
return (char const **)field_list.elems;
360363
}
361364

362365
/** Convert CSV keys according to selected conversion mode. Replacement is static but in-place. */

src/rtl_433.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,9 @@ int main(int argc, char **argv) {
13631363
}
13641364
fprintf(stderr, "\n");
13651365

1366-
start_outputs(cfg, well_known_output_fields(cfg));
1366+
char const **well_known = well_known_output_fields(cfg);
1367+
start_outputs(cfg, well_known);
1368+
free(well_known);
13671369

13681370
if (cfg->out_block_size < MINIMAL_BUF_LENGTH ||
13691371
cfg->out_block_size > MAXIMAL_BUF_LENGTH) {

0 commit comments

Comments
 (0)