diff options
author | Sheri Bernstein <bernstein@adacore.com> | 2023-07-27 17:12:37 +0000 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-08-07 13:14:36 +0200 |
commit | f51b8e5b7f44bbb70b8cef270d35ae7ac6ff41ef (patch) | |
tree | 1d7625066c5e8e8c9f69ba0384e449be4ff7fbc0 | |
parent | 41d7d32c04d431a74cfe030c4a1d8c07ec6c6813 (diff) | |
download | gcc-f51b8e5b7f44bbb70b8cef270d35ae7ac6ff41ef.zip gcc-f51b8e5b7f44bbb70b8cef270d35ae7ac6ff41ef.tar.gz gcc-f51b8e5b7f44bbb70b8cef270d35ae7ac6ff41ef.tar.bz2 |
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.
-rw-r--r-- | gcc/ada/libgnat/s-parame__qnx.adb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/gcc/ada/libgnat/s-parame__qnx.adb b/gcc/ada/libgnat/s-parame__qnx.adb index d9b46b6..8a7dfaf 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; ------------------------ |