annotate rvinterf/tmsh/rftablechk.c @ 1011:6d9b10633f10 default tip

etmsync Pirelli IMEI retrieval: fix poor use of printf() Bug reported by Vadim Yanitskiy <fixeria@osmocom.org>: the construct where a static-allocated string was passed to printf() without any format arguments causes newer compilers to report a security problem. Given that formatted output is not needed here, just fixed string output, change printf() to fputs(), and direct the error message to stderr while at it.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 23 May 2024 17:29:57 +0000
parents bc23c1cd30ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
123
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains the function that checks if the table format
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * and rftw index match.
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "localtypes.h"
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "l1tm.h"
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "exitcodes.h"
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 static struct table_match {
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 int index;
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char *format;
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 } matchlist[] = {
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {RX_AGC_TABLE, "agc-table"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 {AFC_PARAMS, "afcparams"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {RX_AGC_GLOBAL_PARAMS, "agc-global-params"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {RX_IL_2_AGC_MAX, "il2agc"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {RX_IL_2_AGC_PWR, "il2agc"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {RX_IL_2_AGC_AV, "il2agc"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 {TX_LEVELS, "tx-levels"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {TX_CAL_CHAN, "tx-calchan"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 {TX_CAL_TEMP, "tx-caltemp"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 {RX_CAL_CHAN, "rx-calchan"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 {RX_CAL_TEMP, "rx-caltemp"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 {RX_AGC_PARAMS, "rx-agc-params"},
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 {0, 0}
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 };
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 rftw_index_format_check(index, format)
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 char *format;
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 {
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 struct table_match *tp;
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (!strcmp(format, "raw"))
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 return(0);
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 for (tp = matchlist; tp->index; tp++) {
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (tp->index == index) {
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 if (!strcmp(format, tp->format))
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 return(0);
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 printf("error: read table of type %s, expected %s\n",
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 format, tp->format);
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 return(ERROR_USAGE);
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 return(0);
bc23c1cd30ae fc-tmsh: rftw format consistency check implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }