Patchwork [Ada] Correct error handling in Initialize

login
register
mail settings
Submitter Arnaud Charlet
Date Oct. 13, 2011, 10:17 a.m.
Message ID <20111013101742.GA17277@adacore.com>
Download mbox | patch
Permalink /patch/119400/
State New
Headers show

Comments

Arnaud Charlet - Oct. 13, 2011, 10:17 a.m.
This change fixes the error handling circuitry in the initialization routine
for suspension objects so that Storage_Error is propagated as intended if
the allocation of the underlying OS entities fails.

No test (requires system resource allocation failure).

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-10-13  Thomas Quinot  <quinot@adacore.com>

	* s-taprop-posix.adb (Initialize): Always raise Storage_Error
	if we fail to initialize CV attributes or CV.

Patch

Index: s-taprop-posix.adb
===================================================================
--- s-taprop-posix.adb	(revision 179894)
+++ s-taprop-posix.adb	(working copy)
@@ -1089,9 +1089,7 @@ 
          Result := pthread_mutex_destroy (S.L'Access);
          pragma Assert (Result = 0);
 
-         if Result = ENOMEM then
-            raise Storage_Error;
-         end if;
+         raise Storage_Error;
       end if;
 
       Result := pthread_cond_init (S.CV'Access, Cond_Attr'Access);
@@ -1101,11 +1099,10 @@ 
          Result := pthread_mutex_destroy (S.L'Access);
          pragma Assert (Result = 0);
 
-         if Result = ENOMEM then
-            Result := pthread_condattr_destroy (Cond_Attr'Access);
-            pragma Assert (Result = 0);
-            raise Storage_Error;
-         end if;
+         Result := pthread_condattr_destroy (Cond_Attr'Access);
+         pragma Assert (Result = 0);
+
+         raise Storage_Error;
       end if;
 
       Result := pthread_condattr_destroy (Cond_Attr'Access);