Skip to content

Commit

Permalink
Change CodePeer annotations to GNATSAS
Browse files Browse the repository at this point in the history
  • Loading branch information
dinkelk committed Aug 14, 2024
1 parent ff02221 commit 21f236e
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 47 deletions.
12 changes: 6 additions & 6 deletions gen/templates/array/name-validation.adb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ package body {{ name }}.Validation is
for Jdx in R (Idx)'Range loop
if not R (Idx)(Jdx)'Valid then
Errant_Field := Count + 1;
pragma Annotate (CodePeer, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
return False;
end if;
end loop;
{% else %}
if not R (Idx)'Valid then
Errant_Field := Count + 1;
pragma Annotate (CodePeer, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
return False;
end if;
{% endif %}
Expand Down Expand Up @@ -115,14 +115,14 @@ package body {{ name }}.Validation is
for Jdx in R (Idx)'Range loop
if not R (Idx)(Jdx)'Valid then
Errant_Field := Count + 1;
pragma Annotate (CodePeer, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
return False;
end if;
end loop;
{% else %}
if not R (Idx)'Valid then
Errant_Field := Count + 1;
pragma Annotate (CodePeer, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
return False;
end if;
{% endif %}
Expand Down Expand Up @@ -186,14 +186,14 @@ package body {{ name }}.Validation is
for Jdx in R (Idx)'Range loop
if not R (Idx)(Jdx)'Valid then
Errant_Field := Count + 1;
pragma Annotate (CodePeer, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
return False;
end if;
end loop;
{% else %}
if not R (Idx)'Valid then
Errant_Field := Count + 1;
pragma Annotate (CodePeer, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some array elements may not be bit-constrained and thus will always be valid");
return False;
end if;
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions gen/templates/commands/name_commands.adb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ package body {{ name }} is

-- Set the command length and id and initialize buffer:
if Len > Command_Types.Command_Arg_Buffer_Length_Type'Last then
pragma Annotate (CodePeer, False_Positive, "test always false",
"Some CodePeer can prove the Len can never be too large so this code does not execute. This is OK.");
pragma Annotate (GNATSAS, False_Positive, "test always false",
"GNAT SAS can prove the Len can never be too large so this code does not execute. This is OK.");
return Failure;
pragma Annotate (CodePeer, False_Positive, "dead code",
"Some CodePeer can prove the Len can never be too large so this code does not execute. This is OK.");
pragma Annotate (GNATSAS, False_Positive, "dead code",
"GNAT SAS can prove the Len can never be too large so this code does not execute. This is OK.");
end if;
Cmd := (Header => (Source_Id => Self.Source_Id, Id => Self.Get_{{ command.name }}_Id, Arg_Buffer_Length => Len), Arg_Buffer => [others => 0]);

Expand Down
24 changes: 12 additions & 12 deletions gen/templates/component/component-name.adb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ package body Component.{{ name }} is
Dispatch_To : constant Dispatch_Procedure := Dispatch_Table (Id_Record.Id);
begin
Dispatch_To (Self{% if connectors.arrayed_invokee() %}, Id_Record.Index{% endif %}, Bytes (Bytes'First .. Bytes'First + Length - 1));
pragma Annotate (CodePeer, False_Positive, "range check", "We never put items on queue larger than Bytes'Length.");
pragma Annotate (GNASAS, False_Positive, "range check", "We never put items on queue larger than Bytes'Length.");
end;
-- Error was returned:
when Error =>
Expand Down Expand Up @@ -305,7 +305,7 @@ package body Component.{{ name }} is
Dispatch_To : constant Dispatch_Procedure := Dispatch_Table (Id_Record.Id);
begin
Dispatch_To (Self{% if connectors.arrayed_invokee() %}, Id_Record.Index{% endif %}, Bytes (Bytes'First .. Bytes'First + Length - 1));
pragma Annotate (CodePeer, False_Positive, "range check", "We never put items on queue larger than Bytes'Length.");
pragma Annotate (GNATSAS, False_Positive, "range check", "We never put items on queue larger than Bytes'Length.");
end;
-- The dispatch function MUST release the lock when finished.
return True;
Expand Down Expand Up @@ -381,7 +381,7 @@ package body Component.{{ name }} is
-- Push failed due to serialization problem, return to caller.
when Serialization_Failure =>
return Message_Dropped;
pragma Annotate (CodePeer, False_Positive, "dead code",
pragma Annotate (GNATSAS, False_Positive, "dead code",
"Some types can never fail to serialize, thus this code will never be executed.");
{% endif %}
{% if connectors.requires_priority_queue() %}
Expand Down Expand Up @@ -497,7 +497,7 @@ package body Component.{{ name }} is
{% endif %}
{% else %}
overriding procedure Cycle (Self : in out Base_Instance) is
pragma Annotate (CodePeer, Intentional, "subp always fails",
pragma Annotate (GNATSAS, Intentional, "subp always fails",
"Intentional - this subp should never be called on a component without a task.");
Ignore : Base_Instance renames Self;
begin
Expand Down Expand Up @@ -658,7 +658,7 @@ package body Component.{{ name }} is
begin
-- This type we serialized successfully, it should always deserialize successfully.
pragma Assert (Ser_Status = Success);
pragma Annotate (CodePeer, False_Positive, "assertion", "Assertion will only fail in case of data corruption of software bug.");
pragma Annotate (GNATSAS, False_Positive, "assertion", "Assertion will only fail in case of data corruption of software bug.");
-- The calculated length of the type should always equal the number of bytes received in the function.
pragma Assert (Bytes'Length = Num_Bytes_Deserialized);
end;
Expand Down Expand Up @@ -799,7 +799,7 @@ package body Component.{{ name }} is
-- hope user sees the event and corrects the problem.
Full_Queue_Behavior => Connector_Types.Drop
);
pragma Annotate (CodePeer, False_Positive, "range check",
pragma Annotate (GNATSAS, False_Positive, "range check",
"The command ID cannot be out of range since range checking is done in Set_Id_Bases.");
-- Sleep a bit, so as to not stress out the command router component's queue.
Sleep.Sleep_Us (Configuration.Command_Registration_Delay);
Expand Down Expand Up @@ -833,7 +833,7 @@ package body Component.{{ name }} is
{% endif %}
begin
pragma Assert (Cmd.Header.Id = Self.Command_Id_Base + {{ loop.index0 }});
pragma Annotate (CodePeer, False_Positive, "assertion", "Internal routing ensures this is true.");
pragma Annotate (GNATSAS, False_Positive, "assertion", "Internal routing ensures this is true.");

{% if command.type %}
{% if command.type_model and command.type_model.variable_length %}
Expand All @@ -843,7 +843,7 @@ package body Component.{{ name }} is
-- actually deserialized. This "padding" is simply ignored.
Stat := Arg_Deserializer.From_Byte_Array (Args, Cmd.Arg_Buffer (Cmd.Arg_Buffer'First .. Cmd.Arg_Buffer'First + Cmd.Header.Arg_Buffer_Length - 1), Num_Bytes_Deserialized);
if Stat = Success and then Cmd.Header.Arg_Buffer_Length >= Num_Bytes_Deserialized then
pragma Annotate (CodePeer, Intentional, "condition predetermined", "Sometimes the length can never be too large based on its type, and that is just fine.");
pragma Annotate (GNATSAS, Intentional, "condition predetermined", "Sometimes the length can never be too large based on its type, and that is just fine.");
declare
{% else %}
-- Check the command argument length and make sure it is valid.
Expand All @@ -854,7 +854,7 @@ package body Component.{{ name }} is
{% endif %}
{% if command.type_model %}
Errant_Field : Unsigned_32 := 0;
pragma Annotate (CodePeer, Intentional, "unused assignment", "Sometimes the type can never be invalid, and in that case Errant_Field will never be needed.");
pragma Annotate (GNATSAS, Intentional, "unused assignment", "Sometimes the type can never be invalid, and in that case Errant_Field will never be needed.");
Args_Valid : constant Boolean := {{ command.type_package }}.Validation.Valid (Args, Errant_Field);
{% else %}
Errant_Field : constant Unsigned_32 := 0;
Expand Down Expand Up @@ -1029,7 +1029,7 @@ package body Component.{{ name }} is
{% endif %}
begin
pragma Assert (Par.Header.Id = Self.Parameter_Id_Base + {{ loop.index0 }});
pragma Annotate (CodePeer, False_Positive, "assertion", "Internal routing ensures this is true.");
pragma Annotate (GNATSAS, False_Positive, "assertion", "Internal routing ensures this is true.");

-- Check the parameter buffer length and make sure it is valid.
if Par.Header.Buffer_Length = Buffer_Deserializer.Serialized_Length then
Expand All @@ -1038,7 +1038,7 @@ package body Component.{{ name }} is
Par_To_Stage : constant {{ par.type }} := Buffer_Deserializer.From_Byte_Array (Par.Buffer (Par.Buffer'First .. Par.Buffer'First + Buffer_Deserializer.Serialized_Length - 1));
{% if par.type_model %}
Errant_Field : Unsigned_32 := 0;
pragma Annotate (CodePeer, Intentional, "unused assignment", "Sometimes the type can never be invalid, and in that case Errant_Field will never be needed.");
pragma Annotate (GNATSAS, Intentional, "unused assignment", "Sometimes the type can never be invalid, and in that case Errant_Field will never be needed.");
Args_Valid : constant Boolean := {{ par.type_package }}.Validation.Valid (Par_To_Stage, Errant_Field);
{% else %}
Errant_Field : constant Unsigned_32 := 0;
Expand Down Expand Up @@ -1114,7 +1114,7 @@ package body Component.{{ name }} is
package Buffer_Deserializer is new Serializer ({{ par.type }});
Value : constant {{ par.type }} := Self.Staged_Parameters.Get_{{ par.name }};
{% endif %}
pragma Annotate (CodePeer, False_Positive, "validity check",
pragma Annotate (GNATSAS, False_Positive, "validity check",
"Defaults for parameter values are always initialized within Staged_Parameters protected object definition.");
begin
pragma Assert (Par.Header.Id = Self.Parameter_Id_Base + {{ loop.index0 }});
Expand Down
30 changes: 15 additions & 15 deletions gen/templates/record/name-validation.adb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ package body {{ name }}.Validation is
-- Make sure sizing field for the variable length field is valid for its type.
if not R.{{ field.variable_length }}'Valid then
Errant_Field := {{ field.variable_length_field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;

Expand All @@ -60,7 +60,7 @@ package body {{ name }}.Validation is
Variable_Length := Integer (R.{{ field.variable_length }}) + Integer ({{ field.variable_length_offset }});
if Variable_Length > R.{{ field.name }}'Length then
Errant_Field := {{ field.variable_length_field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "since this field is already 'Valid, it may be not too large by definition");
pragma Annotate (GNATSAS, Intentional, "dead code", "since this field is already 'Valid, it may be not too large by definition");
return False;
end if;

Expand All @@ -83,7 +83,7 @@ package body {{ name }}.Validation is
for E of R.{{ field.name }} (R.{{ field.name }}'First .. R.{{ field.name }}'First + Variable_Length - 1) loop
if not E'Valid then
Errant_Field := {{ field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;
end loop;
Expand All @@ -92,7 +92,7 @@ package body {{ name }}.Validation is
for E of R.{{ field.name }} loop
if not E'Valid then
Errant_Field := {{ field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;
end loop;
Expand All @@ -101,7 +101,7 @@ package body {{ name }}.Validation is
{% if field.name not in variable_length_sizing_fields.keys() %}
if not R.{{ field.name }}'Valid then
Errant_Field := {{ field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;
{% else %}
Expand Down Expand Up @@ -185,7 +185,7 @@ package body {{ name }}.Validation is
-- Make sure sizing field for the variable length field is valid for its type.
if not R.{{ field.variable_length }}'Valid then
Errant_Field := {{ field.variable_length_field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;

Expand All @@ -194,7 +194,7 @@ package body {{ name }}.Validation is
Variable_Length := Integer (R.{{ field.variable_length }}) + Integer ({{ field.variable_length_offset }});
if Variable_Length > R.{{ field.name }}'Length then
Errant_Field := {{ field.variable_length_field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "since this field is already 'Valid, it may be not too large by definition");
pragma Annotate (GNATSAS, Intentional, "dead code", "since this field is already 'Valid, it may be not too large by definition");
return False;
end if;

Expand All @@ -217,7 +217,7 @@ package body {{ name }}.Validation is
for E of R.{{ field.name }} (R.{{ field.name }}'First .. R.{{ field.name }}'First + Variable_Length - 1) loop
if not E'Valid then
Errant_Field := {{ field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;
end loop;
Expand All @@ -226,7 +226,7 @@ package body {{ name }}.Validation is
for E of R.{{ field.name }} loop
if not E'Valid then
Errant_Field := {{ field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;
end loop;
Expand All @@ -235,7 +235,7 @@ package body {{ name }}.Validation is
{% if field.name not in variable_length_sizing_fields.keys() %}
if not R.{{ field.name }}'Valid then
Errant_Field := {{ field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;
{% else %}
Expand Down Expand Up @@ -318,7 +318,7 @@ package body {{ name }}.Validation is
-- Make sure sizing field for the variable length field is valid for its type.
if not R.{{ field.variable_length }}'Valid then
Errant_Field := {{ field.variable_length_field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;

Expand All @@ -327,7 +327,7 @@ package body {{ name }}.Validation is
Variable_Length := Integer (R.{{ field.variable_length }}) + Integer ({{ field.variable_length_offset }});
if Variable_Length > R.{{ field.name }}'Length then
Errant_Field := {{ field.variable_length_field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "since this field is already 'Valid, it may be not too large by definition");
pragma Annotate (GNATSAS, Intentional, "dead code", "since this field is already 'Valid, it may be not too large by definition");
return False;
end if;

Expand All @@ -349,7 +349,7 @@ package body {{ name }}.Validation is
for E of R.{{ field.name }} (R.{{ field.name }}'First .. R.{{ field.name }}'First + Variable_Length - 1) loop
if not E'Valid then
Errant_Field := {{ field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;
end loop;
Expand All @@ -358,7 +358,7 @@ package body {{ name }}.Validation is
for E of R.{{ field.name }} loop
if not E'Valid then
Errant_Field := {{ field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;
end loop;
Expand All @@ -367,7 +367,7 @@ package body {{ name }}.Validation is
{% if field.name not in variable_length_sizing_fields.keys() %}
if not R.{{ field.name }}'Valid then
Errant_Field := {{ field.start_field_number }};
pragma Annotate (CodePeer, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
pragma Annotate (GNATSAS, Intentional, "dead code", "some fields may not be bit-constrained and thus will always be valid");
return False;
end if;
{% else %}
Expand Down
Loading

0 comments on commit 21f236e

Please sign in to comment.