Stefan Schuermans commited on 2012-05-06 17:12:30
Showing 1 changed files, with 17 additions and 17 deletions.
... | ... |
@@ -24,7 +24,7 @@ |
24 | 24 |
*/ |
25 | 25 |
uint32_t DFS_GetPtnStart(uint8_t unit, uint8_t *scratchsector, uint8_t pnum, uint8_t *pactive, uint8_t *pptype, uint32_t *psize) |
26 | 26 |
{ |
27 |
- uint32_t result; |
|
27 |
+ uint32_t result = 0; |
|
28 | 28 |
PMBR mbr = (PMBR) scratchsector; |
29 | 29 |
|
30 | 30 |
// DOS ptable supports maximum 4 partitions |
... | ... |
@@ -161,7 +161,7 @@ uint32_t DFS_GetVolInfo(uint8_t unit, uint8_t *scratchsector, uint32_t startsect |
161 | 161 |
*/ |
162 | 162 |
uint32_t DFS_GetFAT(PVOLINFO volinfo, uint8_t *scratch, uint32_t *scratchcache, uint32_t cluster) |
163 | 163 |
{ |
164 |
- uint32_t offset, sector, result; |
|
164 |
+ uint32_t offset = 0, sector = 0, result = 0; |
|
165 | 165 |
|
166 | 166 |
if (volinfo->filesystem == FAT12) { |
167 | 167 |
offset = cluster + (cluster / 2); |
... | ... |
@@ -256,7 +256,7 @@ uint32_t DFS_GetFAT(PVOLINFO volinfo, uint8_t *scratch, uint32_t *scratchcache, |
256 | 256 |
*/ |
257 | 257 |
uint32_t DFS_SetFAT(PVOLINFO volinfo, uint8_t *scratch, uint32_t *scratchcache, uint32_t cluster, uint32_t new_contents) |
258 | 258 |
{ |
259 |
- uint32_t offset, sector, result; |
|
259 |
+ uint32_t offset = 0, sector = 0, result = 0; |
|
260 | 260 |
if (volinfo->filesystem == FAT12) { |
261 | 261 |
offset = cluster + (cluster / 2); |
262 | 262 |
new_contents &=0xfff; |
... | ... |
@@ -379,7 +379,7 @@ uint32_t DFS_SetFAT(PVOLINFO volinfo, uint8_t *scratch, uint32_t *scratchcache, |
379 | 379 |
// 4 bits of the FAT32 cluster value. It's unclear what these bits will be used |
380 | 380 |
// for; in every example I've encountered they are always zero. |
381 | 381 |
result = DFS_WriteSector(volinfo->unit, scratch, *scratchcache, 1); |
382 |
- // mirror the FAT into copy 2 |
|
382 |
+ // mirror the FAT into copy 2 - XXX |
|
383 | 383 |
if (DFS_OK == result) |
384 | 384 |
result = DFS_WriteSector(volinfo->unit, scratch, (*scratchcache)+volinfo->secperfat, 1); |
385 | 385 |
} |
... | ... |
@@ -641,7 +641,7 @@ uint32_t DFS_GetNext(PVOLINFO volinfo, PDIRINFO dirinfo, PDIRENT dirent) |
641 | 641 |
*/ |
642 | 642 |
uint32_t DFS_GetFreeDirEnt(PVOLINFO volinfo, uint8_t *path, PDIRINFO di, PDIRENT de) |
643 | 643 |
{ |
644 |
- uint32_t tempclus,i; |
|
644 |
+ uint32_t tempclus = 0, i = 0; |
|
645 | 645 |
|
646 | 646 |
if (DFS_OpenDir(volinfo, path, di)) |
647 | 647 |
return DFS_NOTFOUND; |
... | ... |
@@ -870,10 +870,10 @@ uint32_t DFS_OpenFile(PVOLINFO volinfo, uint8_t *path, uint8_t mode, uint8_t *sc |
870 | 870 |
*/ |
871 | 871 |
uint32_t DFS_ReadFile(PFILEINFO fileinfo, uint8_t *scratch, uint8_t *buffer, uint32_t *successcount, uint32_t len) |
872 | 872 |
{ |
873 |
- uint32_t remain; |
|
873 |
+ uint32_t remain = 0; |
|
874 | 874 |
uint32_t result = DFS_OK; |
875 |
- uint32_t sector; |
|
876 |
- uint32_t bytesread; |
|
875 |
+ uint32_t sector = 0; |
|
876 |
+ uint32_t bytesread = 0; |
|
877 | 877 |
|
878 | 878 |
// Don't try to read past EOF |
879 | 879 |
if (len > fileinfo->filelen - fileinfo->pointer) |
... | ... |
@@ -976,7 +976,8 @@ uint32_t DFS_ReadFile(PFILEINFO fileinfo, uint8_t *scratch, uint8_t *buffer, uin |
976 | 976 |
*/ |
977 | 977 |
void DFS_Seek(PFILEINFO fileinfo, uint32_t offset, uint8_t *scratch) |
978 | 978 |
{ |
979 |
- uint32_t tempint; |
|
979 |
+ uint32_t tempint = 0; |
|
980 |
+ uint16_t endcluster = 0; |
|
980 | 981 |
|
981 | 982 |
// larwe 9/16/06 bugfix split case 0a/0b and changed fallthrough handling |
982 | 983 |
// Case 0a - Return immediately for degenerate case |
... | ... |
@@ -1021,10 +1022,9 @@ void DFS_Seek(PFILEINFO fileinfo, uint32_t offset, uint8_t *scratch) |
1021 | 1022 |
fileinfo->volinfo->secperclus * SECTOR_SIZE; |
1022 | 1023 |
|
1023 | 1024 |
// seek by clusters |
1024 |
- // larwe 9/30/06 bugfix changed .rem to .quot in both div calls |
|
1025 |
- while (div(fileinfo->pointer, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot != |
|
1026 |
- div(fileinfo->pointer + offset, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot) { |
|
1027 |
- |
|
1025 |
+ // canny/reza 5/7 added endcluster related code |
|
1026 |
+ endcluster = div(offset, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot; |
|
1027 |
+ while ((uint16_t)div(fileinfo->pointer, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot != endcluster) { |
|
1028 | 1028 |
fileinfo->cluster = DFS_GetFAT(fileinfo->volinfo, scratch, &tempint, fileinfo->cluster); |
1029 | 1029 |
// Abort if there was an error |
1030 | 1030 |
if (fileinfo->cluster == 0x0ffffff7) { |
... | ... |
@@ -1048,7 +1048,7 @@ uint32_t DFS_UnlinkFile(PVOLINFO volinfo, uint8_t *path, uint8_t *scratch) |
1048 | 1048 |
{ |
1049 | 1049 |
FILEINFO fi; |
1050 | 1050 |
uint32_t cache = 0; |
1051 |
- uint32_t tempclus; |
|
1051 |
+ uint32_t tempclus = 0; |
|
1052 | 1052 |
|
1053 | 1053 |
// DFS_OpenFile gives us all the information we need to delete it |
1054 | 1054 |
if (DFS_OK != DFS_OpenFile(volinfo, path, DFS_READ, scratch, &fi)) |
... | ... |
@@ -1083,10 +1083,10 @@ uint32_t DFS_UnlinkFile(PVOLINFO volinfo, uint8_t *path, uint8_t *scratch) |
1083 | 1083 |
*/ |
1084 | 1084 |
uint32_t DFS_WriteFile(PFILEINFO fileinfo, uint8_t *scratch, uint8_t *buffer, uint32_t *successcount, uint32_t len) |
1085 | 1085 |
{ |
1086 |
- uint32_t remain; |
|
1086 |
+ uint32_t remain = 0; |
|
1087 | 1087 |
uint32_t result = DFS_OK; |
1088 |
- uint32_t sector; |
|
1089 |
- uint32_t byteswritten; |
|
1088 |
+ uint32_t sector = 0; |
|
1089 |
+ uint32_t byteswritten = 0; |
|
1090 | 1090 |
|
1091 | 1091 |
// Don't allow writes to a file that's open as readonly |
1092 | 1092 |
if (!(fileinfo->mode & DFS_WRITE)) |
1093 | 1093 |