public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4507] ada: Add Codepeer Exemption + simplify TO_C code. Date: Tue, 6 Dec 2022 14:00:54 +0000 (GMT) [thread overview] Message-ID: <20221206140054.183883848E35@sourceware.org> (raw) https://gcc.gnu.org/g:c690f116b64be820cd47a554bffeadd9907fed2a commit r13-4507-gc690f116b64be820cd47a554bffeadd9907fed2a Author: Liaiss Merzougue <merzougue@adacore.com> Date: Fri Apr 2 09:29:03 2021 +0000 ada: Add Codepeer Exemption + simplify TO_C code. This patch simplify the TO_C code to have a single branch for raising exception. Furthermore, adding pragma annotate for codepeer to ignore uninitialized value since this is caused because we have input check before the initialization. gcc/ada/ * libgnat/i-c.adb (To_C): Simplify code for having a single exception raise. Add pragma annotate about uninitialized value which happen only on exception raising. Diff: --- gcc/ada/libgnat/i-c.adb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/gcc/ada/libgnat/i-c.adb b/gcc/ada/libgnat/i-c.adb index 4b50d18a5a1..28660219b6e 100644 --- a/gcc/ada/libgnat/i-c.adb +++ b/gcc/ada/libgnat/i-c.adb @@ -186,7 +186,7 @@ is (Item : char_array; Trim_Nul : Boolean := True) return String is - Count : Natural; + Count : Natural := 0; From : size_t; begin @@ -1177,7 +1177,7 @@ is To : size_t; begin - if Target'Length < Item'Length then + if Target'Length < Item'Length + (if Append_Nul then 1 else 0) then raise Constraint_Error; else @@ -1210,17 +1210,14 @@ is Target'First + (Item'Length - 1))'Initialized); if Append_Nul then - if To > Target'Last then - raise Constraint_Error; - else - Target (To) := char32_nul; - Count := Item'Length + 1; - end if; - + Target (To) := char32_nul; + Count := Item'Length + 1; else Count := Item'Length; end if; end if; end To_C; + pragma Annotate (CodePeer, False_Positive, "validity check", + "Count is only uninitialized on abnormal return."); end Interfaces.C;
reply other threads:[~2022-12-06 14:00 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221206140054.183883848E35@sourceware.org \ --to=dkm@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).