ao-tools: Fix warnings in ao-tools
authorKeith Packard <keithp@keithp.com>
Thu, 3 Jan 2019 19:41:49 +0000 (11:41 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 3 Jan 2019 20:09:58 +0000 (12:09 -0800)
None of these appear likely to have caused actual problems.

Signed-off-by: Keith Packard <keithp@keithp.com>
28 files changed:
ao-tools/ao-cal-freq/ao-cal-freq.c
ao-tools/ao-chaosread/ao-chaosread.c
ao-tools/ao-dbg/ao-dbg-command.c
ao-tools/ao-dbg/ao-dbg-main.c
ao-tools/ao-dbg/ao-dbg-parse.c
ao-tools/ao-dbg/ao-dbg.h
ao-tools/ao-dump-up/ao-dump-up.c
ao-tools/ao-dumpflash/ao-dumpflash.c
ao-tools/ao-edit-telem/ao-edit-telem.c
ao-tools/ao-rawload/ao-rawload.c
ao-tools/ao-send-telem/ao-send-telem.c
ao-tools/ao-sky-flash/sky_bin.c
ao-tools/ao-sky-flash/sky_flash.c
ao-tools/ao-sky-flash/sky_flash.h
ao-tools/ao-sky-flash/sky_serial.c
ao-tools/ao-telem/ao-telem.c
ao-tools/ao-test-baro/ao-test-baro.c
ao-tools/ao-test-flash/ao-test-flash.c
ao-tools/ao-test-gps/ao-test-gps.c
ao-tools/ao-test-igniter/ao-test-igniter.c
ao-tools/ao-usbload/ao-usbload.c
ao-tools/ao-usbtrng/ao-usbtrng.c
ao-tools/lib/ao-editaltos.c
ao-tools/lib/ao-hex.c
ao-tools/lib/cc-convert.c
ao-tools/lib/cc-logfile.c
ao-tools/lib/cc-process.c
ao-tools/lib/cc-usbdev.c

index 838fbab3a6f6947844a97e692d58515b75093b44..b9efb8f68a46e55539400754c8a2959fcd3dbb74 100644 (file)
@@ -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) {
index 5c0de1257fbded71cda28e0d7dbaaf2fcffaba7c..b0a6168aa71e991fc7f7e7ee86f55d299c4d2074 100644 (file)
@@ -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;
index 11c521e88d5a47614137a651f4ac6a02a7a252fa..f0e6b6cec51049e657a716e1fcc2a5586be312f8 100644 (file)
@@ -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
index 8c87903510b5a325297afca854a1944a4cccbdaf..772701a94315543260b101747021a63ea213930e 100644 (file)
@@ -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;
index ba69183431c823f508bb318afff89c291ee77abc..b61d68b8db7266cf1696cda57a1162c92a6a3851 100644 (file)
@@ -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)
 {
index edc650a506c8d99c2c2a20de7ba43443a0726b3e..2ced54b5a8d815585c98bdb0b66899ebd58ba183 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <ccdbg.h>
 #include <cc.h>
+#include <ctype.h>
 
 extern char *s51_prompt;
 extern struct ccdbg *s51_dbg;
index df05088cadaf2e4cb33d0b61482eac66f5210a5e..6866ef592997e7fe24bf9954d5c6fa81c3b56faa 100644 (file)
@@ -21,6 +21,7 @@
 #include <unistd.h>
 #include <getopt.h>
 #include <string.h>
+#include <ctype.h>
 #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;
index 3cd21e66ac83ed0e8c228c5b38ec03e13dcbec86..5c789fb934fecb8b7582cdc4cbe0c7688521114c 100644 (file)
@@ -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) {
index e2795ede180908ac11acb1b2ff93c4e24ba80660..92cde3dc73ee88be3532550bff301a6bd5e241ee 100644 (file)
@@ -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;
 
index 17ed73cae20e5ac58a7176ba8583459da22b7e07..c139cda1b46876fb03db2b3b2bfc27efd9044ee6 100644 (file)
@@ -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;
index a4fc85b7300d8f15b4e6483dd26ca02c16f7e05a..4b8f3c4f2639c182a70d1a2f0b2b266cfe0c1e6b 100644 (file)
@@ -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));
index d728d0c22413cb30dde726b1e8309cb5417e7d48..2f7719ff97fc4913013b22ebacb099f943ea28f7 100644 (file)
@@ -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)
index 7dbb69548b92cf7b259d8a42c8f180f75918f012..16c6ee424d8394205d946b7e5b15bfa52b8a1c23 100644 (file)
 #include <stdint.h>
 #include <stdarg.h>
 #include <getopt.h>
+#include <unistd.h>
 #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 <tty-name>]\n"
                "          [--device <device-name>]\n"
-               "          [--loader <srec bootloader file>]\n"
                "          [--firmware <binary firmware file>]\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;
index 6dcbbf7242e2df334b77f554d7a2b76fbd5e3dec..1a8dfb9e48330bd5312ab58ec3052d0fbd0960b1 100644 (file)
@@ -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);
 
index 94b0b156502149e171f041258e50de764cc733ae..e56ab9238176b45047a8b0dd4345f8641ad93b54 100644 (file)
@@ -16,7 +16,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-#define _BSD_SOURCE
+#define _DEFAULT_SOURCE 1
 #include <termios.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -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:
index aa54a1b9a4ffe5b0a1906ff211e659197118d463..7ab2310a5dc4a4ec3620147087b2305d4249a788 100644 (file)
@@ -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;
index 36c805c201bdb34181bd719b7c85b828eeccce00..d617a83aa876d4c95c7cbfcca513cd21bf6fd04d 100644 (file)
@@ -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;
 
index 5cbc56d750ae6f4b6e19da8c1cf6562b3d71e6a6..dc5d8ebcded8835f9b273b09bb7cf904ab52c12d 100644 (file)
@@ -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) {
index 5012028c15bfe088bf67aad2a6ed9ccf5962f05c..09ad3e8cb18bc38b888c9de69812d8bf78a086a0 100644 (file)
@@ -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;
 
index c426e1bd28d34742e6034308f5c75ee9d79eac34..62e6c702c1c14d80a0d67327d90df1bca7e5ee5c 100644 (file)
@@ -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;
 
index 31ee138a3679584779eeda813997667b8ba3ffd9..6da57bace36b6b53ad6ff51bf0b078373311ebf9 100644 (file)
@@ -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;
index 0362f1b46af98560dc220181e36afa64392b9f3d..46bdbeb23edd61b21a711d2e2dc0948977056e6b 100644 (file)
@@ -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;
index 0600965309834527964843bedd596821ae93d40a..a51b7dbe8a129b2635bf26085edcb5cd1ca19dd6 100644 (file)
@@ -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;
 
index 2ceed7ab4f2ba9e1791c3283e23b735e93a2aaea..73f3d7bed61dde5534fe03631ff62e4b563f49c9 100644 (file)
@@ -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)
index 0f7fa809ecd77864be20d5b866529f7c1c082308..4a7e52fc8d3fa55ec1ebb14e38f3e28ac04909a5 100644 (file)
@@ -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)
 {
index 88ddda58822ee487da4a7b07a6620bc3b914bb9c..c193b1c7f5ec4f3a3120dfa392898b1d42d90b21 100644 (file)
@@ -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)
index 74b02a74b53af644707d816aca2c40c453456b37..f2307a8207818436391dd6560f18699424d4aba5 100644 (file)
@@ -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;
index 6c3ba5910b3602465e918dc38f7bcec04d700e9f..b176170013574dbfcbb0324f1781c4d5ef1ef469 100644 (file)
@@ -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;