From 6f729ff46b2f4531db68f0af85e7e9fe0f6d1969 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 3 Jan 2019 11:41:49 -0800 Subject: [PATCH] ao-tools: Fix warnings in ao-tools None of these appear likely to have caused actual problems. Signed-off-by: Keith Packard --- ao-tools/ao-cal-freq/ao-cal-freq.c | 81 ++-------------------- ao-tools/ao-chaosread/ao-chaosread.c | 17 +---- ao-tools/ao-dbg/ao-dbg-command.c | 20 +++--- ao-tools/ao-dbg/ao-dbg-main.c | 6 +- ao-tools/ao-dbg/ao-dbg-parse.c | 35 ---------- ao-tools/ao-dbg/ao-dbg.h | 1 + ao-tools/ao-dump-up/ao-dump-up.c | 13 +--- ao-tools/ao-dumpflash/ao-dumpflash.c | 9 +-- ao-tools/ao-edit-telem/ao-edit-telem.c | 12 +--- ao-tools/ao-rawload/ao-rawload.c | 2 - ao-tools/ao-send-telem/ao-send-telem.c | 4 -- ao-tools/ao-sky-flash/sky_bin.c | 2 +- ao-tools/ao-sky-flash/sky_flash.c | 18 ++--- ao-tools/ao-sky-flash/sky_flash.h | 8 ++- ao-tools/ao-sky-flash/sky_serial.c | 10 ++- ao-tools/ao-telem/ao-telem.c | 3 +- ao-tools/ao-test-baro/ao-test-baro.c | 35 +--------- ao-tools/ao-test-flash/ao-test-flash.c | 36 +--------- ao-tools/ao-test-gps/ao-test-gps.c | 35 +--------- ao-tools/ao-test-igniter/ao-test-igniter.c | 34 ++------- ao-tools/ao-usbload/ao-usbload.c | 13 +--- ao-tools/ao-usbtrng/ao-usbtrng.c | 3 +- ao-tools/lib/ao-editaltos.c | 2 - ao-tools/lib/ao-hex.c | 10 +-- ao-tools/lib/cc-convert.c | 3 - ao-tools/lib/cc-logfile.c | 4 +- ao-tools/lib/cc-process.c | 4 +- ao-tools/lib/cc-usbdev.c | 2 +- 28 files changed, 68 insertions(+), 354 deletions(-) diff --git a/ao-tools/ao-cal-freq/ao-cal-freq.c b/ao-tools/ao-cal-freq/ao-cal-freq.c index 838fbab3..b9efb8f6 100644 --- a/ao-tools/ao-cal-freq/ao-cal-freq.c +++ b/ao-tools/ao-cal-freq/ao-cal-freq.c @@ -50,35 +50,6 @@ static void usage(char *program) exit(1); } -void -done(struct cc_usb *cc, int code) -{ - cc_usb_close(cc); - exit (code); -} - -static int -ends_with(char *whole, char *suffix) -{ - int whole_len = strlen(whole); - int suffix_len = strlen(suffix); - - if (suffix_len > whole_len) - return 0; - return strcmp(whole + whole_len - suffix_len, suffix) == 0; -} - -static int -starts_with(char *whole, char *prefix) -{ - int whole_len = strlen(whole); - int prefix_len = strlen(prefix); - - if (prefix_len > whole_len) - return 0; - return strncmp(whole, prefix, prefix_len) == 0; -} - static char ** tok(char *line) { char **strs = malloc (sizeof (char *)), *str; @@ -94,16 +65,6 @@ tok(char *line) { return strs; } -static void -free_strs(char **strs) { - char *str; - int i; - - for (i = 0; (str = strs[i]) != NULL; i++) - free(str); - free(strs); -} - struct flash { struct flash *next; char line[512]; @@ -132,21 +93,8 @@ flash(struct cc_usb *usb) return head; } -static void -free_flash(struct flash *b) { - struct flash *n; - - while (b) { - n = b->next; - free_strs(b->strs); - free(b); - b = n; - } -} - -char ** +static char ** find_flash(struct flash *b, char *word0) { - int i; for (;b; b = b->next) { if (strstr(b->line, word0)) return b->strs; @@ -154,21 +102,7 @@ find_flash(struct flash *b, char *word0) { return NULL; } -void -await_key(void) -{ - struct termios termios, termios_save; - char buf[512]; - - tcgetattr(0, &termios); - termios_save = termios; - cfmakeraw(&termios); - tcsetattr(0, TCSAFLUSH, &termios); - read(0, buf, sizeof (buf)); - tcsetattr(0, TCSAFLUSH, &termios_save); -} - -int +static int do_save(struct cc_usb *usb) { int ret = 0; @@ -192,7 +126,7 @@ do_save(struct cc_usb *usb) return ret; } -int +static int do_output(char *output, int cur_cal) { printf ("Saving calibration value to file \"%s\"\n", output); @@ -220,7 +154,7 @@ do_output(char *output, int cur_cal) return ret; } -int +static int do_cal(char *tty, int save, char *output) { struct cc_usb *usb = NULL; @@ -313,18 +247,11 @@ int main (int argc, char **argv) { char *device = NULL; - char *filename; - Elf *e; - unsigned int s; - int i; int c; - int tries; char *tty = NULL; - int success; int verbose = 0; int save = 1; int ret = 0; - int expected_size; char *output = NULL; while ((c = getopt_long(argc, argv, "vnT:D:o:", options, NULL)) != -1) { diff --git a/ao-tools/ao-chaosread/ao-chaosread.c b/ao-tools/ao-chaosread/ao-chaosread.c index 5c0de125..b0a6168a 100644 --- a/ao-tools/ao-chaosread/ao-chaosread.c +++ b/ao-tools/ao-chaosread/ao-chaosread.c @@ -36,7 +36,7 @@ struct chaoskey { int kernel_active; }; -libusb_device_handle * +static libusb_device_handle * chaoskey_match(libusb_device *dev, char *match_serial) { struct libusb_device_descriptor desc; @@ -96,7 +96,7 @@ out: return 0; } -struct chaoskey * +static struct chaoskey * chaoskey_open(char *serial) { struct chaoskey *ck; @@ -161,22 +161,11 @@ out: return NULL; } -void -chaoskey_close(struct chaoskey *ck) -{ - libusb_release_interface(ck->handle, 0); - if (ck->kernel_active) - libusb_attach_kernel_driver(ck->handle, 0); - libusb_close(ck->handle); - libusb_exit(ck->ctx); - free(ck); -} - #define COOKED_ENDPOINT 0x85 #define RAW_ENDPOINT 0x86 #define FLASH_ENDPOINT 0x87 -int +static int chaoskey_read(struct chaoskey *ck, int endpoint, void *buffer, int len) { uint8_t *buf = buffer; diff --git a/ao-tools/ao-dbg/ao-dbg-command.c b/ao-tools/ao-dbg/ao-dbg-command.c index 11c521e8..f0e6b6ce 100644 --- a/ao-tools/ao-dbg/ao-dbg-command.c +++ b/ao-tools/ao-dbg/ao-dbg-command.c @@ -106,6 +106,7 @@ command_di (int argc, char **argv) return command_error; length = (int) end - (int) start + 1; status = ccdbg_read_memory(s51_dbg, start + 0xff00, memory, length); + (void) status; dump_bytes(memory, length, start, "0x%02x "); return command_success; } @@ -126,6 +127,7 @@ command_ds (int argc, char **argv) return command_error; length = (int) end - (int) start + 1; status = ccdbg_read_sfr(s51_dbg, start, memory, length); + (void) status; dump_bytes(memory, length, start, "0x%02x "); return command_success; } @@ -146,6 +148,7 @@ command_dx (int argc, char **argv) return command_error; length = (int) end - (int) start + 1; status = ccdbg_read_memory(s51_dbg, start, memory, length); + (void) status; dump_bytes(memory, length, start, "0x%04x "); return command_success; } @@ -282,11 +285,10 @@ enable_breakpoints(void) enable_breakpoint(b); } -enum command_result +static enum command_result set_breakpoint(uint16_t address, int temporary) { int b; - uint8_t status; for (b = 0; b < CC_NUM_BREAKPOINTS; b++) { if (breakpoints[b].enabled == 0) break; @@ -307,11 +309,10 @@ set_breakpoint(uint16_t address, int temporary) return command_success; } -enum command_result +static enum command_result clear_breakpoint(uint16_t address, int temporary) { int b; - uint8_t status; for (b = 0; b < CC_NUM_BREAKPOINTS; b++) { if (breakpoints[b].enabled != 0 && @@ -333,7 +334,7 @@ clear_breakpoint(uint16_t address, int temporary) } -int +static int find_breakpoint(uint16_t address) { int b; @@ -372,7 +373,6 @@ command_break (int argc, char **argv) enum command_result command_clear (int argc, char **argv) { - int b; uint16_t address; enum command_result result; @@ -384,7 +384,7 @@ command_clear (int argc, char **argv) return clear_breakpoint(address, 0); } -void +static void cc_stopped(uint8_t status) { uint16_t pc; @@ -411,7 +411,7 @@ cc_stopped(uint8_t status) } } -uint8_t +static uint8_t cc_step(uint16_t pc) { int b; @@ -585,8 +585,6 @@ static enum command_result info_breakpoints(int argc, char **argv) { int b; - uint16_t address; - enum command_result result; if (argc == 1) { s51_printf("Num Type Disp Hit Cnt Address What\n"); @@ -599,7 +597,7 @@ info_breakpoints(int argc, char **argv) } return command_success; } - + return command_syntax; } static enum command_result diff --git a/ao-tools/ao-dbg/ao-dbg-main.c b/ao-tools/ao-dbg/ao-dbg-main.c index 8c879035..772701a9 100644 --- a/ao-tools/ao-dbg/ao-dbg-main.c +++ b/ao-tools/ao-dbg/ao-dbg-main.c @@ -50,7 +50,8 @@ usage(void) exit(1); } -void s51_sigint() +static void +s51_sigint(int signum) { s51_interrupted = 1; } @@ -64,7 +65,7 @@ static const struct option options[] = { int main(int argc, char **argv) { - int flags, opt; + int opt; char *endptr; while ((opt = getopt_long(argc, argv, "PVvHhmt:X:c:r:Z:s:S:p:T:", options, NULL)) != -1) { @@ -242,7 +243,6 @@ s51_check_input(void) { struct pollfd input; int r; - int c; input.fd = fileno(s51_input); input.events = POLLIN; diff --git a/ao-tools/ao-dbg/ao-dbg-parse.c b/ao-tools/ao-dbg/ao-dbg-parse.c index ba691834..b61d68b8 100644 --- a/ao-tools/ao-dbg/ao-dbg-parse.c +++ b/ao-tools/ao-dbg/ao-dbg-parse.c @@ -68,41 +68,6 @@ static struct command_function functions[] = { #define TRUE 1 #endif -static int -string_to_int(char *s, int *v) -{ - char *endptr; - - if (isdigit(s[0]) || s[0] == '-' || s[0] == '+') { - *v = strtol(s, &endptr, 0); - if (endptr == s) - return FALSE; - } else if (*s == '\'') { - s++; - if (*s == '\\') { - s++; - switch (*s) { - case 'n': - *v = '\n'; - break; - case 't': - *v = '\t'; - break; - default: - *v = (int) *s; - break; - } - } else - *v = (int) *s; - s++; - if (*s != '\'') - return FALSE; - } - else - return FALSE; - return TRUE; -} - struct command_function * command_string_to_function(struct command_function *functions, char *name) { diff --git a/ao-tools/ao-dbg/ao-dbg.h b/ao-tools/ao-dbg/ao-dbg.h index edc650a5..2ced54b5 100644 --- a/ao-tools/ao-dbg/ao-dbg.h +++ b/ao-tools/ao-dbg/ao-dbg.h @@ -18,6 +18,7 @@ #include #include +#include extern char *s51_prompt; extern struct ccdbg *s51_dbg; diff --git a/ao-tools/ao-dump-up/ao-dump-up.c b/ao-tools/ao-dump-up/ao-dump-up.c index df05088c..6866ef59 100644 --- a/ao-tools/ao-dump-up/ao-dump-up.c +++ b/ao-tools/ao-dump-up/ao-dump-up.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "cc-usb.h" #include "cc.h" @@ -39,17 +40,6 @@ static void usage(char *program) exit(1); } -static uint8_t -log_checksum(int d[8]) -{ - uint8_t sum = 0x5a; - int i; - - for (i = 0; i < 8; i++) - sum += (uint8_t) d[i]; - return -sum; -} - static int get_nonwhite(struct cc_usb *cc, int timeout) { int c; @@ -147,7 +137,6 @@ main (int argc, char **argv) char *tty = NULL; char *device = NULL; int c; - char line[8192]; int nsamples; int i; int crc; diff --git a/ao-tools/ao-dumpflash/ao-dumpflash.c b/ao-tools/ao-dumpflash/ao-dumpflash.c index 3cd21e66..5c789fb9 100644 --- a/ao-tools/ao-dumpflash/ao-dumpflash.c +++ b/ao-tools/ao-dumpflash/ao-dumpflash.c @@ -51,24 +51,17 @@ main (int argc, char **argv) int c; char line[8192]; FILE *out; - char *filename; int serial_number = 0; int freq = 434550; char *call = "N0CALL"; - int flight = 0; - char cmd; int block; int addr; int received_addr; int data[8]; - int done; int i; - int column; int remote = 0; - int any_valid; - int invalid; int storage_size = 0; - char *out_name; + char *out_name = NULL; while ((c = getopt_long(argc, argv, "T:D:F:C:o:R", options, NULL)) != -1) { switch (c) { diff --git a/ao-tools/ao-edit-telem/ao-edit-telem.c b/ao-tools/ao-edit-telem/ao-edit-telem.c index e2795ede..92cde3dc 100644 --- a/ao-tools/ao-edit-telem/ao-edit-telem.c +++ b/ao-tools/ao-edit-telem/ao-edit-telem.c @@ -73,7 +73,7 @@ int pending = 1; static void dump_saved(void); -void +static void doit(union ao_telemetry_all *telem) { double lat, lon; @@ -142,10 +142,9 @@ int main (int argc, char **argv) { char line[80]; - int c, i, ret; - char *s; + int c, i, ret = 0; FILE *file; - int serial; + while ((c = getopt_long(argc, argv, "l:L:", options, NULL)) != -1) { switch (c) { case 'L': @@ -166,11 +165,6 @@ main (int argc, char **argv) ret++; continue; } - s = strstr(argv[i], "-serial-"); - if (s) - serial = atoi(s + 8); - else - serial = 0; while (fgets(line, sizeof (line), file)) { union ao_telemetry_all telem; diff --git a/ao-tools/ao-rawload/ao-rawload.c b/ao-tools/ao-rawload/ao-rawload.c index 17ed73ca..c139cda1 100644 --- a/ao-tools/ao-rawload/ao-rawload.c +++ b/ao-tools/ao-rawload/ao-rawload.c @@ -38,8 +38,6 @@ int main (int argc, char **argv) { struct ccdbg *dbg; - uint8_t status; - uint16_t pc; struct ao_hex_file *hex; struct ao_hex_image *image; char *filename; diff --git a/ao-tools/ao-send-telem/ao-send-telem.c b/ao-tools/ao-send-telem/ao-send-telem.c index a4fc85b7..4b8f3c4f 100644 --- a/ao-tools/ao-send-telem/ao-send-telem.c +++ b/ao-tools/ao-send-telem/ao-send-telem.c @@ -114,7 +114,6 @@ static const char *state_names[] = { static void send_telem(struct cc_usb *cc, union ao_telemetry_all *telem) { - int rssi = (int8_t) telem->generic.rssi / 2 - 74; int i; uint8_t *b; @@ -170,9 +169,7 @@ main (int argc, char **argv) char line[80]; int c, i, ret = 0; int freq = 434550; - char *s; FILE *file; - int serial; uint16_t last_tick; int started; int realtime = 0; @@ -239,7 +236,6 @@ main (int argc, char **argv) if (fake) { union ao_telemetry_all telem; - uint16_t tick; int i; memset(&telem, '\0', sizeof (telem)); diff --git a/ao-tools/ao-sky-flash/sky_bin.c b/ao-tools/ao-sky-flash/sky_bin.c index d728d0c2..2f7719ff 100644 --- a/ao-tools/ao-sky-flash/sky_bin.c +++ b/ao-tools/ao-sky-flash/sky_bin.c @@ -48,7 +48,7 @@ skytraq_send_bin(int fd, const char *filename) size = ftell(file); rewind(file); - sprintf(message, "BINSIZE = %d Checksum = %d Loopnumber = %d ", size, cksum, 1); + sprintf(message, "BINSIZE = %ld Checksum = %d Loopnumber = %d ", size, cksum, 1); ret = skytraq_cmd_wait(fd, message, strlen(message) + 1, "OK", 20000); if (ret < 0) diff --git a/ao-tools/ao-sky-flash/sky_flash.c b/ao-tools/ao-sky-flash/sky_flash.c index 7dbb6954..16c6ee42 100644 --- a/ao-tools/ao-sky-flash/sky_flash.c +++ b/ao-tools/ao-sky-flash/sky_flash.c @@ -23,12 +23,12 @@ #include #include #include +#include #include "cc.h" static const struct option options[] = { { .name = "tty", .has_arg = 1, .val = 'T' }, { .name = "device", .has_arg = 1, .val = 'D' }, - { .name = "loader", .has_arg = 1, .val = 'l' }, { .name = "firmware", .has_arg = 1, .val = 'f' }, { .name = "query", .has_arg = 0, .val = 'q' }, { .name = "raw", .has_arg = 0, .val = 'r' }, @@ -46,7 +46,6 @@ usage(char *program) fprintf(stderr, "usage: %s [--tty ]\n" " [--device ]\n" - " [--loader ]\n" " [--firmware ]\n" " [--query]\n" " [--quiet]\n" @@ -54,7 +53,7 @@ usage(char *program) exit(1); } -int +static int skytraq_expect(int fd, uint8_t want, int timeout) { int c; @@ -66,12 +65,12 @@ skytraq_expect(int fd, uint8_t want, int timeout) { return 0; } -int +static int skytraq_wait_reply(int fd, uint8_t reply, uint8_t *buf, uint8_t reply_len) { for(;;) { uint8_t a, b; - uint8_t cksum_computed, cksum_read; + uint8_t cksum_computed; int len; switch (skytraq_expect(fd, 0xa0, 10000)) { case -1: @@ -135,16 +134,10 @@ int main(int argc, char **argv) { int fd; - char buf[512]; int ret; - FILE *input; - long size; - unsigned char cksum; int c; - char message[1024]; char *tty = NULL; char *device = NULL; - char *loader = "srec_115200.bin"; char *file = NULL; int query = 0; int raw = 0; @@ -157,9 +150,6 @@ main(int argc, char **argv) case 'D': device = optarg; break; - case 'l': - loader = optarg; - break; case 'f': file = optarg; break; diff --git a/ao-tools/ao-sky-flash/sky_flash.h b/ao-tools/ao-sky-flash/sky_flash.h index 6dcbbf72..1a8dfb9e 100644 --- a/ao-tools/ao-sky-flash/sky_flash.h +++ b/ao-tools/ao-sky-flash/sky_flash.h @@ -31,7 +31,7 @@ int skytraq_setcomm(int fd, int baudrate); int -skytraq_write(int fd, const char *data, int len); +skytraq_write(int fd, const void *data, int len); int skytraq_waitchar(int fd, int timeout); @@ -42,6 +42,12 @@ skytraq_waitstatus(int fd, const char *status, int timeout); void skytraq_flush(int fd); +int +skytraq_millis(void); + +void +skytraq_dbg_newline(void); + int skytraq_cmd_wait(int fd, const char *message, int len, const char *status, int timeout); diff --git a/ao-tools/ao-sky-flash/sky_serial.c b/ao-tools/ao-sky-flash/sky_serial.c index 94b0b156..e56ab923 100644 --- a/ao-tools/ao-sky-flash/sky_serial.c +++ b/ao-tools/ao-sky-flash/sky_serial.c @@ -16,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define _BSD_SOURCE +#define _DEFAULT_SOURCE 1 #include #include #include @@ -98,11 +98,10 @@ skytraq_open(const char *path) #define US_PER_CHAR (1000000 / BPS) int -skytraq_write(int fd, const char *data, int len) +skytraq_write(int fd, const void *d, int len) { - const char *d = data; + const char *data = d; int r; - int us; skytraq_dbg_printf (0, "%4d: ", len); if (len < 70) @@ -116,7 +115,6 @@ skytraq_write(int fd, const char *data, int len) r = write(fd, data, this_time); if (r <= 0) return r; - us = r * US_PER_CHAR; usleep(r * US_PER_CHAR); data += r; len -= r; @@ -132,7 +130,7 @@ skytraq_setcomm(int fd, int baudrate) int i; uint8_t cksum; - int target_baudrate; + int target_baudrate = 0; switch(baudrate) { case 4800: diff --git a/ao-tools/ao-telem/ao-telem.c b/ao-tools/ao-telem/ao-telem.c index aa54a1b9..7ab2310a 100644 --- a/ao-tools/ao-telem/ao-telem.c +++ b/ao-tools/ao-telem/ao-telem.c @@ -42,8 +42,7 @@ int main (int argc, char **argv) { char line[80]; - int c, i, ret; - char *s; + int c, i, ret = 0; FILE *file; int serial; int ignore_crc = 0; diff --git a/ao-tools/ao-test-baro/ao-test-baro.c b/ao-tools/ao-test-baro/ao-test-baro.c index 36c805c2..d617a83a 100644 --- a/ao-tools/ao-test-baro/ao-test-baro.c +++ b/ao-tools/ao-test-baro/ao-test-baro.c @@ -47,7 +47,7 @@ static void usage(char *program) exit(1); } -void +static void done(struct cc_usb *cc, int code) { /* cc_usb_printf(cc, "a\n"); */ @@ -55,28 +55,6 @@ done(struct cc_usb *cc, int code) exit (code); } -static int -ends_with(char *whole, char *suffix) -{ - int whole_len = strlen(whole); - int suffix_len = strlen(suffix); - - if (suffix_len > whole_len) - return 0; - return strcmp(whole + whole_len - suffix_len, suffix) == 0; -} - -static int -starts_with(char *whole, char *prefix) -{ - int whole_len = strlen(whole); - int prefix_len = strlen(prefix); - - if (prefix_len > whole_len) - return 0; - return strncmp(whole, prefix, prefix_len) == 0; -} - static char ** tok(char *line) { char **strs = malloc (sizeof (char *)), *str; @@ -140,16 +118,15 @@ free_baro(struct baro *b) { } } -char ** +static char ** find_baro(struct baro *b, char *word0) { - int i; for (;b; b = b->next) if (b->strs[0] && !strcmp(b->strs[0], word0)) return b->strs; return NULL; } -int +static int do_baro(struct cc_usb *usb) { struct baro *b = baro(usb); char **temp = find_baro(b, "Temperature:"); @@ -185,15 +162,9 @@ int main (int argc, char **argv) { char *device = NULL; - char *filename; - Elf *e; - unsigned int s; - int i; int c; - int tries; struct cc_usb *cc = NULL; char *tty = NULL; - int success; int verbose = 0; int ret = 0; diff --git a/ao-tools/ao-test-flash/ao-test-flash.c b/ao-tools/ao-test-flash/ao-test-flash.c index 5cbc56d7..dc5d8ebc 100644 --- a/ao-tools/ao-test-flash/ao-test-flash.c +++ b/ao-tools/ao-test-flash/ao-test-flash.c @@ -47,35 +47,13 @@ static void usage(char *program) exit(1); } -void +static void done(struct cc_usb *cc, int code) { cc_usb_close(cc); exit (code); } -static int -ends_with(char *whole, char *suffix) -{ - int whole_len = strlen(whole); - int suffix_len = strlen(suffix); - - if (suffix_len > whole_len) - return 0; - return strcmp(whole + whole_len - suffix_len, suffix) == 0; -} - -static int -starts_with(char *whole, char *prefix) -{ - int whole_len = strlen(whole); - int prefix_len = strlen(prefix); - - if (prefix_len > whole_len) - return 0; - return strncmp(whole, prefix, prefix_len) == 0; -} - static char ** tok(char *line) { char **strs = malloc (sizeof (char *)), *str; @@ -141,9 +119,8 @@ free_flash(struct flash *b) { } } -char ** +static char ** find_flash(struct flash *b, char *word0) { - int i; for (;b; b = b->next) { if (strstr(b->line, word0)) return b->strs; @@ -151,7 +128,7 @@ find_flash(struct flash *b, char *word0) { return NULL; } -int +static int do_flash(struct cc_usb *usb, int expected_size) { struct flash *b = flash(usb); char **size = find_flash(b, "Storage size:"); @@ -188,18 +165,11 @@ int main (int argc, char **argv) { char *device = NULL; - char *filename; - Elf *e; - unsigned int s; - int i; int c; - int tries; struct cc_usb *cc = NULL; char *tty = NULL; - int success; int verbose = 0; int ret = 0; - int expected_size; while ((c = getopt_long(argc, argv, "rT:D:c:s:v:", options, NULL)) != -1) { switch (c) { diff --git a/ao-tools/ao-test-gps/ao-test-gps.c b/ao-tools/ao-test-gps/ao-test-gps.c index 5012028c..09ad3e8c 100644 --- a/ao-tools/ao-test-gps/ao-test-gps.c +++ b/ao-tools/ao-test-gps/ao-test-gps.c @@ -47,7 +47,7 @@ static void usage(char *program) exit(1); } -void +static void done(struct cc_usb *cc, int code) { /* cc_usb_printf(cc, "a\n"); */ @@ -55,28 +55,6 @@ done(struct cc_usb *cc, int code) exit (code); } -static int -ends_with(char *whole, char *suffix) -{ - int whole_len = strlen(whole); - int suffix_len = strlen(suffix); - - if (suffix_len > whole_len) - return 0; - return strcmp(whole + whole_len - suffix_len, suffix) == 0; -} - -static int -starts_with(char *whole, char *prefix) -{ - int whole_len = strlen(whole); - int prefix_len = strlen(prefix); - - if (prefix_len > whole_len) - return 0; - return strncmp(whole, prefix, prefix_len) == 0; -} - static char ** tok(char *line) { char **strs = malloc (sizeof (char *)), *str; @@ -140,16 +118,15 @@ free_gps(struct gps *b) { } } -char ** +static char ** find_gps(struct gps *b, char *word0) { - int i; for (;b; b = b->next) if (b->strs[0] && !strcmp(b->strs[0], word0)) return b->strs; return NULL; } -int +static int do_gps(struct cc_usb *usb) { int count = 0; @@ -186,15 +163,9 @@ int main (int argc, char **argv) { char *device = NULL; - char *filename; - Elf *e; - unsigned int s; - int i; int c; - int tries; struct cc_usb *cc = NULL; char *tty = NULL; - int success; int verbose = 0; int ret = 0; diff --git a/ao-tools/ao-test-igniter/ao-test-igniter.c b/ao-tools/ao-test-igniter/ao-test-igniter.c index c426e1bd..62e6c702 100644 --- a/ao-tools/ao-test-igniter/ao-test-igniter.c +++ b/ao-tools/ao-test-igniter/ao-test-igniter.c @@ -47,7 +47,7 @@ static void usage(char *program) exit(1); } -void +static void done(struct cc_usb *cc, int code) { /* cc_usb_printf(cc, "a\n"); */ @@ -55,28 +55,6 @@ done(struct cc_usb *cc, int code) exit (code); } -static int -ends_with(char *whole, char *suffix) -{ - int whole_len = strlen(whole); - int suffix_len = strlen(suffix); - - if (suffix_len > whole_len) - return 0; - return strcmp(whole + whole_len - suffix_len, suffix) == 0; -} - -static int -starts_with(char *whole, char *prefix) -{ - int whole_len = strlen(whole); - int prefix_len = strlen(prefix); - - if (prefix_len > whole_len) - return 0; - return strncmp(whole, prefix, prefix_len) == 0; -} - struct igniter { struct igniter *next; char name[512]; @@ -96,7 +74,7 @@ igniters(struct cc_usb *usb) cc_usb_getline(usb, line, sizeof (line)); if (strstr(line, "software-version")) break; - if (sscanf(line, "Igniter: %s Status: %s", &name, &status) == 2) { + if (sscanf(line, "Igniter: %s Status: %s", name, status) == 2) { struct igniter *i = malloc (sizeof (struct igniter)); strcpy(i->name, name); strcpy(i->status, status); @@ -125,6 +103,7 @@ find_igniter(struct igniter *i, char *name) for (; i; i = i->next) if (strcmp(i->name, name) == 0) return i; + return NULL; } static int @@ -134,7 +113,7 @@ do_igniter(struct cc_usb *usb, char *name) struct igniter *this = find_igniter(all, name); if (!this) { struct igniter *i; - printf("no igniter %s found in"); + printf("no igniter %s found in", name); for (i = all; i; i = i->next) printf(" %s", i->name); printf("\n"); @@ -157,15 +136,10 @@ int main (int argc, char **argv) { char *device = NULL; - char *filename; - Elf *e; - unsigned int s; int i; int c; - int tries; struct cc_usb *cc = NULL; char *tty = NULL; - int success; int verbose = 0; int ret = 0; diff --git a/ao-tools/ao-usbload/ao-usbload.c b/ao-tools/ao-usbload/ao-usbload.c index 31ee138a..6da57bac 100644 --- a/ao-tools/ao-usbload/ao-usbload.c +++ b/ao-tools/ao-usbload/ao-usbload.c @@ -96,7 +96,7 @@ static void usage(char *program) exit(1); } -void +static void done(struct cc_usb *cc, int code) { /* cc_usb_printf(cc, "a\n"); */ @@ -124,7 +124,7 @@ ucs2len(uint16_t *ucs2) return len; } -int +static int putucs4(uint32_t c, FILE *file) { char d; @@ -162,23 +162,14 @@ main (int argc, char **argv) { char *device = NULL; char *filename; - Elf *e; int raw = 0; char *serial_end; unsigned int serial = 0; - char *serial_ucs2; - int serial_ucs2_len; - char serial_int[2]; - unsigned int s; - int i; - int string_num; uint32_t cal = 0; - char cal_int[4]; char *cal_end; int c; int was_flashed = 0; struct ao_hex_image *load; - int tries; struct cc_usb *cc = NULL; char *tty = NULL; int success; diff --git a/ao-tools/ao-usbtrng/ao-usbtrng.c b/ao-tools/ao-usbtrng/ao-usbtrng.c index 0362f1b4..46bdbeb2 100644 --- a/ao-tools/ao-usbtrng/ao-usbtrng.c +++ b/ao-tools/ao-usbtrng/ao-usbtrng.c @@ -46,7 +46,7 @@ static void usage(char *program) exit(1); } -void +static void done(struct cc_usb *cc, int code) { cc_usb_close(cc); @@ -57,7 +57,6 @@ int main (int argc, char **argv) { char *device = NULL; - char *filename; int i; int c; struct cc_usb *cc = NULL; diff --git a/ao-tools/lib/ao-editaltos.c b/ao-tools/lib/ao-editaltos.c index 06009653..a51b7dbe 100644 --- a/ao-tools/lib/ao-editaltos.c +++ b/ao-tools/lib/ao-editaltos.c @@ -53,8 +53,6 @@ int ao_num_symbols = NUM_SYMBOLS; static bool rewrite(struct ao_hex_image *load, unsigned address, uint8_t *data, int length) { - int i; - if (address < load->address || load->address + load->length < address + length) return false; diff --git a/ao-tools/lib/ao-hex.c b/ao-tools/lib/ao-hex.c index 2ceed7ab..73f3d7be 100644 --- a/ao-tools/lib/ao-hex.c +++ b/ao-tools/lib/ao-hex.c @@ -113,9 +113,9 @@ ao_hex_read_record(struct ao_hex_input *input) struct ao_hex_record *record = NULL; enum ao_hex_read_state state = read_marker; char c; - int nhexbytes; - uint32_t hex; - uint32_t ndata; + int nhexbytes = 0; + uint32_t hex = 0; + uint32_t ndata = 0; uint8_t checksum; while (state != read_done) { @@ -451,8 +451,8 @@ ao_hex_image_free(struct ao_hex_image *image) free(image); } -uint32_t min(uint32_t a, uint32_t b) { return a < b ? a : b; } -uint32_t max(uint32_t a, uint32_t b) { return a > b ? a : b; } +static uint32_t min(uint32_t a, uint32_t b) { return a < b ? a : b; } +static uint32_t max(uint32_t a, uint32_t b) { return a > b ? a : b; } struct ao_hex_image * ao_hex_image_cat(struct ao_hex_image *a, struct ao_hex_image *b) diff --git a/ao-tools/lib/cc-convert.c b/ao-tools/lib/cc-convert.c index 0f7fa809..4a7e52fc 100644 --- a/ao-tools/lib/cc-convert.c +++ b/ao-tools/lib/cc-convert.c @@ -213,9 +213,6 @@ cc_pressure_to_altitude(double pressure) * 2.82V * 2047 / 3.3 counts/V = 1749 counts/115 kPa */ -static const double counts_per_kPa = 27 * 2047 / 3300; -static const double counts_at_101_3kPa = 1674.0; - double cc_barometer_to_pressure(double count) { diff --git a/ao-tools/lib/cc-logfile.c b/ao-tools/lib/cc-logfile.c index 88ddda58..c193b1c7 100644 --- a/ao-tools/lib/cc-logfile.c +++ b/ao-tools/lib/cc-logfile.c @@ -306,8 +306,8 @@ cc_log_read(FILE *file) { struct cc_flightraw *f; char line[8192]; - double ground_pres; - int ground_pres_count; + double ground_pres = 0.0; + int ground_pres_count = 0; f = calloc(1, sizeof (struct cc_flightraw)); if (!f) diff --git a/ao-tools/lib/cc-process.c b/ao-tools/lib/cc-process.c index 74b02a74..f2307a82 100644 --- a/ao-tools/lib/cc-process.c +++ b/ao-tools/lib/cc-process.c @@ -46,8 +46,8 @@ struct cc_flightcooked * cc_flight_cook(struct cc_flightraw *raw) { struct cc_flightcooked *cooked; - double flight_start; - double flight_stop; + double flight_start = 0; + double flight_stop = 0; int start_set = 0; int stop_set = 0; int i; diff --git a/ao-tools/lib/cc-usbdev.c b/ao-tools/lib/cc-usbdev.c index 6c3ba591..b1761700 100644 --- a/ao-tools/lib/cc-usbdev.c +++ b/ao-tools/lib/cc-usbdev.c @@ -102,7 +102,7 @@ usb_tty(char *sys) struct dirent **namelist; int interface; int num_interfaces; - char endpoint_base[20]; + char endpoint_base[64]; char *endpoint_full; char *tty_dir; int ntty; -- 2.30.2