comparison sd.c @ 56:f0563086040d

Fix more warnings. Note the 'buf might be used uninitialised' warning appears to be a GCC bug.
author Daniel O'Connor <darius@dons.net.au>
date Sun, 07 Apr 2013 22:44:23 +0930
parents b21db2b47a27
children 488085e0c7e1
comparison
equal deleted inserted replaced
55:b21db2b47a27 56:f0563086040d
96 } else if (!strcmp(argv[0], "mount")) { 96 } else if (!strcmp(argv[0], "mount")) {
97 sd_domount(); 97 sd_domount();
98 } else if (!strcmp(argv[0], "rdb")) { 98 } else if (!strcmp(argv[0], "rdb")) {
99 uint32_t addr; 99 uint32_t addr;
100 uint8_t *buf; 100 uint8_t *buf;
101 uint32_t i;
102 101
103 if (argc != 2) { 102 if (argc != 2) {
104 printf("Block to read not specified\n"); 103 printf("Block to read not specified\n");
105 return; 104 return;
106 } 105 }
107 addr = atoi(argv[1]); 106 addr = atoi(argv[1]);
108 107
109 if ((buf = malloc(SD_BLOCK_SIZE)) == NULL) { 108 if ((buf = malloc(SD_BLOCK_SIZE)) == NULL) {
110 printf("Unable to allocate buffer\n"); 109 printf("Unable to allocate buffer\n");
111 return; 110 return;
112 } 111 }
113 112
131 read_exit: 130 read_exit:
132 free(buf); 131 free(buf);
133 } else if (!strcmp(argv[0], "wrb")) { 132 } else if (!strcmp(argv[0], "wrb")) {
134 uint32_t addr; 133 uint32_t addr;
135 uint8_t *buf; 134 uint8_t *buf;
136 uint32_t i; 135 int32_t i;
137 136
138 if (argc < 3) { 137 if (argc < 3) {
139 printf("Block to read and/or fill value(s) not specified\n"); 138 printf("Block to read and/or fill value(s) not specified\n");
140 return; 139 return;
141 } 140 }
208 DWORD sn; 207 DWORD sn;
209 208
210 if ((fserr = f_getlabel("", label, &sn)) != FR_OK) { 209 if ((fserr = f_getlabel("", label, &sn)) != FR_OK) {
211 printf("Unable to read label: %d\n", fserr); 210 printf("Unable to read label: %d\n", fserr);
212 } else { 211 } else {
213 printf("Label: %s Serial: %d\n", label, sn); 212 printf("Label: %s Serial: %ld\n", label, sn);
214 } 213 }
215 214
216 if ((fserr = f_opendir(&d, argc == 1 ? "\\" : argv[1])) != FR_OK) { 215 if ((fserr = f_opendir(&d, argc == 1 ? "\\" : argv[1])) != FR_OK) {
217 printf("Unable to opendir: %d\n", fserr); 216 printf("Unable to opendir: %d\n", fserr);
218 return; 217 return;
229 #if _USE_LFN 228 #if _USE_LFN
230 fn = *fno.lfname ? fno.lfname : fno.fname; 229 fn = *fno.lfname ? fno.lfname : fno.fname;
231 #else 230 #else
232 fn = fno.fname; 231 fn = fno.fname;
233 #endif 232 #endif
234 printf("%-12s %5u %d/%d/%d %02d:%02d:%02d %s%s%s%s%s\n", fn, fno.fsize, 233 printf("%-12s %5lu %d/%d/%d %02d:%02d:%02d %s%s%s%s%s\n", fn, fno.fsize,
235 FAT_YEAR(fno.fdate), FAT_MONTH(fno.fdate), FAT_DAY(fno.fdate), 234 FAT_YEAR(fno.fdate), FAT_MONTH(fno.fdate), FAT_DAY(fno.fdate),
236 FAT_HOUR(fno.ftime), FAT_MIN(fno.ftime), FAT_SEC(fno.ftime), 235 FAT_HOUR(fno.ftime), FAT_MIN(fno.ftime), FAT_SEC(fno.ftime),
237 fno.fattrib & AM_DIR ? "D" : "", fno.fattrib & AM_RDO ? "R" : "", 236 fno.fattrib & AM_DIR ? "D" : "", fno.fattrib & AM_RDO ? "R" : "",
238 fno.fattrib & AM_HID ? "H" : "", fno.fattrib & AM_SYS ? "S" : "", 237 fno.fattrib & AM_HID ? "H" : "", fno.fattrib & AM_SYS ? "S" : "",
239 fno.fattrib & AM_ARC ? "A" : ""); 238 fno.fattrib & AM_ARC ? "A" : "");