From f51b8e5b7f44bbb70b8cef270d35ae7ac6ff41ef Mon Sep 17 00:00:00 2001 From: Sheri Bernstein <bernstein@adacore.com> Date: Thu, 27 Jul 2023 17:12:37 +0000 Subject: [PATCH] ada: Refactor multiple returns 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. --- gcc/ada/libgnat/s-parame__qnx.adb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gcc/ada/libgnat/s-parame__qnx.adb b/gcc/ada/libgnat/s-parame__qnx.adb index d9b46b6f7954..8a7dfaf57d0c 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; ------------------------ -- GitLab