altos: Eliminate warnings in FAT code
authorKeith Packard <keithp@keithp.com>
Sat, 1 Feb 2014 01:44:45 +0000 (17:44 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 9 Feb 2014 04:13:38 +0000 (20:13 -0800)
The FAT file system code wasn't cleaned up when the warning fixes were
done recently.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_bufio.c
src/drivers/ao_fat.c
src/drivers/ao_sdcard.c

index c0fe604a8784943b3bc4033ca2aaa71fdc07c9f9..70e30b67fee98897f22dd473b114b72063d991dc 100644 (file)
@@ -45,7 +45,7 @@ static uint8_t                ao_bufio_mutex;
 #if 0
 #define DBG(...) printf(__VA_ARGS__)
 #else
-#define DBG(...)
+#define DBG(...) (void) 0
 #endif
 
 static inline void
index 1a1b8eb02444007565e15bcf1622dc78dfb0c6c9..cbcd42bc12a5c8a1aafa308072e896bdea12de8f 100644 (file)
@@ -187,7 +187,7 @@ _ao_fat_entry_replace(cluster_t  cluster, cluster_t new_value)
        sector_t                sector;
        cluster_offset_t        offset;
        uint8_t                 *buf;
-       cluster_t               ret;
+       cluster_t               ret = 0;
        cluster_t               old_value;
        uint8_t                 fat;
 
@@ -747,7 +747,7 @@ _ao_fat_current_sector(struct ao_file *file)
        DBG("current sector offset %d size %d\n",
            file->offset, file->dirent->size);
 
-       if (file->offset > file->dirent->size) {
+       if (file->offset > (offset_t) file->dirent->size) {
                printf ("file offset %d larger than size %d\n",
                        file->offset, file->dirent->size);
                return 0xffffffff;
@@ -761,7 +761,7 @@ _ao_fat_current_sector(struct ao_file *file)
                DBG("\treset to start of file %08x\n", file->cluster);
        }
 
-       if (file->cluster_offset + bytes_per_cluster <= file->offset) {
+       if ((offset_t) (file->cluster_offset + bytes_per_cluster) <= file->offset) {
                cluster_t       cluster_distance;
 
                cluster_offset = sector_offset / sectors_per_cluster;
@@ -804,7 +804,7 @@ _ao_fat_invalidate_cluster_offset(struct ao_fat_dirent *dirent)
                if (!file->busy)
                        continue;
                if (file->dirent == dirent) {
-                       if (file->cluster_offset >= dirent->size) {
+                       if (file->cluster_offset >= (offset_t) dirent->size) {
                                file->cluster_offset = 0;
                                file->cluster = dirent->cluster;
                        }
@@ -838,7 +838,7 @@ _ao_fat_set_size(struct ao_file *file, uint32_t size)
 
        DBG ("\tfirst cluster %08x have %d need %d\n", first_cluster, have_clusters, need_clusters);
        if (have_clusters != need_clusters) {
-               if (file->cluster && size > file->cluster_offset) {
+               if (file->cluster && (offset_t) size > file->cluster_offset) {
                        cluster_t       offset_clusters = (file->cluster_offset + bytes_per_cluster) / bytes_per_cluster;
                        cluster_t       extra_clusters = need_clusters - offset_clusters;
                        cluster_t       next_cluster;
@@ -888,6 +888,7 @@ _ao_fat_set_size(struct ao_file *file, uint32_t size)
 static void
 _ao_fat_root_init(uint8_t *dent, char name[11], uint8_t attr)
 {
+       (void) attr;
        memset(dent, '\0', 0x20);
        memmove(dent, name, 11);
 
@@ -1249,7 +1250,7 @@ ao_fat_read(int8_t fd, void *dst, int len)
                goto done;
        }
 
-       if (file->offset + len > file->dirent->size)
+       if (file->offset + len > (offset_t) file->dirent->size)
                len = file->dirent->size - file->offset;
 
        if (len < 0)
@@ -1296,7 +1297,7 @@ ao_fat_write(int8_t fd, void *src, int len)
                goto done;
        }
 
-       if (file->offset + len > file->dirent->size) {
+       if (file->offset + len > (offset_t) file->dirent->size) {
                ret = _ao_fat_set_size(file, file->offset + len);
                if (ret < 0)
                        goto done;
@@ -1424,6 +1425,8 @@ done:
 int8_t
 ao_fat_rename(char old[11], char new[11])
 {
+       (void) old;
+       (void) new;
        return -AO_FAT_EIO;
 }
 
@@ -1499,7 +1502,7 @@ ao_fat_list_cmd(void)
                putchar('.');
                for (; i < 11; i++)
                        putchar(dirent.name[i]);
-               for (i = 0; i < NUM_FAT_ATTR; i++)
+               for (i = 0; i < (int) NUM_FAT_ATTR; i++)
                        putchar (dirent.attr & ao_fat_attr[i].bit ? ao_fat_attr[i].label : ' ');
                printf (" @%08x %d\n", dirent.cluster, dirent.size);
        }
@@ -1507,7 +1510,7 @@ ao_fat_list_cmd(void)
                printf ("readdir failed: %d\n", status);
 }
 
-static uint8_t
+static void
 ao_fat_parse_name(char name[11])
 {
        uint8_t c;
@@ -1560,8 +1563,6 @@ ao_fat_write_cmd(void)
 {
        static char     name[11];
        int8_t          fd;
-       int             cnt, i;
-       static char     buf[64];
        char            c;
        int             status;
 
index 7806bc194a6b910d946498d5a95c66bd258933ed..47188ef3cf171ade2d34e5d6e1d1155e8ca149bd 100644 (file)
@@ -56,13 +56,13 @@ static enum ao_sdtype sdtype;
 #if SDCARD_TRACE
 #define DBG(...) printf(__VA_ARGS__)
 #else
-#define DBG(...)
+#define DBG(...) (void) 0
 #endif
 
 #if SDCARD_WARN
 #define WARN(...) printf(__VA_ARGS__)
 #else
-#define WARN(...)
+#define WARN(...) (void) 0
 #endif
 
 #define later(x,y)     ((int16_t) ((x) - (y)) >= 0)
@@ -100,7 +100,6 @@ ao_sdcard_send_cmd(uint8_t cmd, uint32_t arg)
 {
        uint8_t data[6];
        uint8_t reply;
-       int i;
        uint16_t timeout;
 
        DBG ("\tsend_cmd %d arg %08x\n", cmd, arg);
@@ -111,7 +110,7 @@ ao_sdcard_send_cmd(uint8_t cmd, uint32_t arg)
                        return SDCARD_STATUS_TIMEOUT;
        }
        
-       data[0] = cmd & 0x3f | 0x40;
+       data[0] = (cmd & 0x3f) | 0x40;
        data[1] = arg >> 24;
        data[2] = arg >> 16;
        data[3] = arg >> 8;
@@ -402,7 +401,7 @@ static uint8_t
 _ao_sdcard_reset(void)
 {
        int i;
-       uint8_t ret;
+       uint8_t ret = 0x3f;
        uint8_t response[10];
 
        for (i = 0; i < SDCARD_IDLE_RETRY; i++) {
@@ -419,12 +418,12 @@ _ao_sdcard_reset(void)
         */
        if (ao_sdcard_send_if_cond(0x1aa, response) == SDCARD_STATUS_IDLE_STATE) {
                uint32_t        arg = 0;
-               uint8_t         sdver2 = 0;
+//             uint8_t         sdver2 = 0;
 
                /* Check for SD version 2 */
                if ((response[2] & 0xf) == 1 && response[3] == 0xaa) {
                        arg = 0x40000000;
-                       sdver2 = 1;
+//                     sdver2 = 1;
                }
 
                for (i = 0; i < SDCARD_IDLE_RETRY; i++) {
@@ -487,7 +486,7 @@ ao_sdcard_wait_block_start(void)
 uint8_t
 ao_sdcard_read_block(uint32_t block, uint8_t *data)
 {
-       uint8_t ret;
+       uint8_t ret = 0x3f;
        uint8_t start_block;
        uint8_t crc[2];
        int tries;
@@ -518,6 +517,7 @@ ao_sdcard_read_block(uint32_t block, uint8_t *data)
                        WARN ("read block command failed %d status %02x\n", block, ret);
                        status = _ao_sdcard_send_status();
                        WARN ("\tstatus now %04x\n", status);
+                       (void) status;
                        goto bail;
                }
 
@@ -567,8 +567,6 @@ ao_sdcard_write_block(uint32_t block, uint8_t *data)
        uint8_t response[1];
        uint8_t start_block[8];
        uint16_t status;
-       static uint8_t  check_data[512];
-       int     i;
        int     tries;
 
        ao_sdcard_lock();
@@ -612,7 +610,7 @@ ao_sdcard_write_block(uint32_t block, uint8_t *data)
                if ((response[0] & SDCARD_DATA_RES_MASK) != SDCARD_DATA_RES_ACCEPTED) {
                        int i;
                        WARN("Data not accepted, response");
-                       for (i = 0; i < sizeof (response); i++)
+                       for (i = 0; i < (int) sizeof (response); i++)
                                WARN(" %02x", response[i]);
                        WARN("\n");
                        ret = 0x3f;