Added some very pedantic warning flags
[tpg/acess2.git] / Kernel / vfs / handle.c
index 7d679be..ecf3f5c 100644 (file)
@@ -13,7 +13,9 @@
 #define MAX_KERNEL_FILES       128
 
 // === PROTOTYPES ===
+#if 0
 tVFS_Handle    *VFS_GetHandle(int FD);
+#endif
  int   VFS_AllocHandle(int FD, tVFS_Node *Node, int Mode);
 
 // === GLOBALS ===
@@ -60,14 +62,20 @@ int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode)
                        Uint    addr, size;
                        size = CFGINT(CFG_VFS_MAXFILES) * sizeof(tVFS_Handle);
                        for(addr = 0; addr < size; addr += 0x1000)
-                               MM_Allocate( (Uint)gaUserHandles + addr );
+                       {
+                               if( !MM_Allocate( (Uint)gaUserHandles + addr ) )
+                               {
+                                       Warning("OOM - VFS_AllocHandle");
+                                       Threads_Exit(0, 0xFF);  // Terminate user
+                               }
+                       }
                        memset( gaUserHandles, 0, size );
                }
                // Get a handle
                for(i=0;i<CFGINT(CFG_VFS_MAXFILES);i++)
                {
                        if(gaUserHandles[i].Node)       continue;
-                       gaUserHandles[i].Node = node;
+                       gaUserHandles[i].Node = Node;
                        gaUserHandles[i].Position = 0;
                        gaUserHandles[i].Mode = Mode;
                        return i;
@@ -81,14 +89,20 @@ int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode)
                        Uint    addr, size;
                        size = MAX_KERNEL_FILES * sizeof(tVFS_Handle);
                        for(addr = 0; addr < size; addr += 0x1000)
-                               MM_Allocate( (Uint)gaKernelHandles + addr );
+                       {
+                               if( !MM_Allocate( (Uint)gaKernelHandles + addr ) )
+                               {
+                                       Panic("OOM - VFS_AllocHandle");
+                                       Threads_Exit(0, 0xFF);  // Terminate application (get some space back)
+                               }
+                       }
                        memset( gaKernelHandles, 0, size );
                }
                // Get a handle
                for(i=0;i<MAX_KERNEL_FILES;i++)
                {
                        if(gaKernelHandles[i].Node)     continue;
-                       gaKernelHandles[i].Node = node;
+                       gaKernelHandles[i].Node = Node;
                        gaKernelHandles[i].Position = 0;
                        gaKernelHandles[i].Mode = Mode;
                        return i|VFS_KERNEL_FLAG;

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