ao-tools: Fix warnings in ao-tools
[fw/altos] / ao-tools / ao-sky-flash / sky_serial.c
index 4aeb14581801129c41593461d9e8058d2f71d408..e56ab9238176b45047a8b0dd4345f8641ad93b54 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,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>
@@ -97,27 +98,23 @@ 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)
+               skytraq_dbg_buf(0, data, len);
        while (len) {
                int     this_time = len;
                if (this_time > 128)
                        this_time = 128;
-               if (this_time < 70) {
-                       skytraq_dbg_printf (0, "%4d: ", this_time);
-                       skytraq_dbg_buf(0, data, this_time);
-               } else {
-                       skytraq_dbg_printf (0, "%d bytes (%d remain)", this_time, len);
-               }
+               skytraq_dbg_printf(0, ".");
                fflush(stdout);
                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;
@@ -133,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: