annotate loadtools/lacrc32.c @ 964:a96cb97b66a2

ringtools/imy: fix duplicate definition of tdma_durations[] The bug was reported by Vadim Yanitskiy <fixeria@osmocom.org>, although the present fix is slightly different from the contributed patch: because main.c doesn't need this tdma_durations[] array at all, let's simply remove the reference to this array from main.c rather than turn it into an extern. I no longer remember my original thought flow that resulted (by mistake) in tdma_durations[] being multiply defined in main.c and durations.c. My intent might have been to define all globals in main.c and have the reference in durations.c be an extern - and I missed that extern - but without clear memory, I have no certainty. In any case, having this data array defined in the same module that fills it (durations.c) is sensible, so let's make it the new way.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 31 Aug 2023 19:38:18 +0000
parents 5385aca4d813
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
640
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the function for getting a CRC-32 computation
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * from loadagent.
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdint.h>
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdlib.h>
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern char target_response_line[];
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 crc32_on_target(area_base, area_len, retptr)
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 u_long area_base, area_len, *retptr;
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char arg1[10], arg2[10], *argv[4];
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int stat;
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 char *strtoul_endp;
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 sprintf(arg1, "%lx", area_base);
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 sprintf(arg2, "%lx", area_len);
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 argv[0] = "crc32";
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 argv[1] = arg1;
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 argv[2] = arg2;
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 argv[3] = 0;
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 tpinterf_make_cmd(argv);
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (tpinterf_send_cmd() < 0)
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 return(-1);
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 stat = tpinterf_capture_output_oneline(10); /* 10 s timeout */
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (stat != 1) {
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 errout: fprintf(stderr, "error: malformed response to crc32 command\n");
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return(-1);
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (strlen(target_response_line) != 8)
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 goto errout;
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 *retptr = strtoul(target_response_line, &strtoul_endp, 16);
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (strtoul_endp != target_response_line + 8)
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 goto errout;
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 return(0);
5385aca4d813 fc-loadtool module refactoring: CRC-32 functions split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }