int block = 0, ofs = 0;
Uint size;
void *blockData;
- int bestMatch = -1, bestSize, bestBlock, bestOfs, bestNeedsSplit;
+ int bestMatch = -1;
+ int bestSize=0, bestBlock=0, bestOfs=0, bestNeedsSplit=0;
int nEntries;
ENTER("pNode sName pChild",
base = inode.i_block[0] * disk->BlockSize;
VFS_ReadAt( disk->FD, base, disk->BlockSize, blockData );
block = 0;
+ nEntries = 0;
// Find File
while(size > 0)
{
*/\r
tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options)\r
{\r
- tExt2_Disk *disk;\r
+ tExt2_Disk *disk = NULL;\r
int fd;\r
int groupCount;\r
tExt2_SuperBlock sb;\r
if(sb.s_magic != 0xEF53) {\r
Log_Warning("EXT2", "Volume '%s' is not an EXT2 volume (0x%x != 0xEF53)",\r
Device, sb.s_magic);\r
- VFS_Close(fd);\r
- LEAVE('n');\r
- return NULL;\r
+ goto _error;\r
}\r
\r
if( sb.s_blocks_per_group < MIN_BLOCKS_PER_GROUP ) {\r
disk = malloc(sizeof(tExt2_Disk) + sizeof(tExt2_Group)*groupCount);\r
if(!disk) {\r
Log_Warning("EXT2", "Unable to allocate disk structure");\r
- VFS_Close(fd);\r
- LEAVE('n');\r
- return NULL;\r
+ goto _error;\r
}\r
disk->FD = fd;\r
memcpy(&disk->SuperBlock, &sb, 1024);\r
LEAVE('p', &disk->RootNode);\r
return &disk->RootNode;\r
_error:\r
- free(disk);\r
+ if( disk )\r
+ free(disk);\r
VFS_Close(fd);\r
LEAVE('n');\r
return NULL;\r