[COMMITTED] ada: Refactor multiple returns

Message ID 20230807111641.2855120-1-poulhies@adacore.com
State Unresolved
Headers
Series [COMMITTED] ada: Refactor multiple returns |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Marc Poulhiès Aug. 7, 2023, 11:16 a.m. UTC
  From: Sheri Bernstein <bernstein@adacore.com>

Replace multiple returns by a single return statement with a conditional
expression. This is more readable and maintainable, and also conformant with
a Highly Recommended design principle of ISO 26262-6.

gcc/ada/

	* libgnat/s-parame__qnx.adb: Refactor multiple returns.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/s-parame__qnx.adb | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
  

Patch

diff --git a/gcc/ada/libgnat/s-parame__qnx.adb b/gcc/ada/libgnat/s-parame__qnx.adb
index d9b46b6f795..8a7dfaf57d0 100644
--- a/gcc/ada/libgnat/s-parame__qnx.adb
+++ b/gcc/ada/libgnat/s-parame__qnx.adb
@@ -39,13 +39,11 @@  package body System.Parameters is
 
    function Adjust_Storage_Size (Size : Size_Type) return Size_Type is
    begin
-      if Size = Unspecified_Size then
-         return Default_Stack_Size;
-      elsif Size < Minimum_Stack_Size then
-         return Minimum_Stack_Size;
-      else
-         return Size;
-      end if;
+      return
+         (if Size = Unspecified_Size then Default_Stack_Size
+          elsif Size < Minimum_Stack_Size then Minimum_Stack_Size
+          else Size
+         );
    end Adjust_Storage_Size;
 
    ------------------------
@@ -56,14 +54,16 @@  package body System.Parameters is
       Default_Stack_Size : constant Integer;
       pragma Import (C, Default_Stack_Size, "__gl_default_stack_size");
    begin
-      if Default_Stack_Size = -1 then
-         --  256K is the default stack size on aarch64 QNX
-         return 256 * 1024;
-      elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then
-         return Minimum_Stack_Size;
-      else
-         return Size_Type (Default_Stack_Size);
-      end if;
+      return
+         (if Default_Stack_Size = -1
+          then
+             (256 * 1024) --  256K is the default stack size on aarch64 QNX
+          elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size
+          then
+             Minimum_Stack_Size
+          else
+             Size_Type (Default_Stack_Size)
+         );
    end Default_Stack_Size;
 
    ------------------------