Modules/Ext2 - Fixed compile errors caused by differing compiler versions
[tpg/acess2.git] / KernelLand / Modules / Filesystems / Ext2 / ext2.c
index 5015e14..adf9163 100644 (file)
@@ -95,7 +95,7 @@ int Ext2_Detect(int FD)
 */\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
@@ -118,9 +118,7 @@ tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options)
        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
@@ -137,9 +135,7 @@ tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options)
        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
@@ -201,7 +197,8 @@ tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options)
        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

UCC git Repository :: git.ucc.asn.au