Skip to content

Commit

Permalink
[meta] Remove serialize check for static arrays in structs (#1912)
Browse files Browse the repository at this point in the history
This will prevent to emmit dead code and will not give compiler warning
from gcc >= 12.2
  • Loading branch information
kcudnik authored Oct 13, 2023
1 parent ae1f9b4 commit 37be016
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions meta/serialize.pm
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ sub GetCounterNameAndType
my $countMemberName = $refTypeInfo->{constCount};
my $countType = "uint32_t";

return ($countMemberName, $countType);
return ($countMemberName, $countType, 1);
}

my $count = $refMembersHash->{$name}{count};
Expand Down Expand Up @@ -659,13 +659,20 @@ sub EmitSerializeArray
{
my ($refStructInfoEx, $refTypeInfo) = @_;

my ($countMemberName, $countType) = GetCounterNameAndType($refStructInfoEx, $refTypeInfo);
my ($countMemberName, $countType, $staticArray) = GetCounterNameAndType($refStructInfoEx, $refTypeInfo);

if (not defined $staticArray)
{
# if pointer is static array, then this check is not needed, since it
# always evaluate to false and gcc 12.2 can detect that and issue warning

WriteSource "if ($refTypeInfo->{memberName} == NULL || $countMemberName == 0)";
WriteSource "{";
WriteSource "EMIT(\"null\");";
WriteSource "}";
WriteSource "else";
}

WriteSource "if ($refTypeInfo->{memberName} == NULL || $countMemberName == 0)";
WriteSource "{";
WriteSource "EMIT(\"null\");";
WriteSource "}";
WriteSource "else";
WriteSource "{";
WriteSource "EMIT(\"[\");\n";
WriteSource "$countType idx;\n";
Expand Down

0 comments on commit 37be016

Please sign in to comment.