From 37be0162e090f17c3821b33ff0d79d42bad40215 Mon Sep 17 00:00:00 2001 From: Kamil Cudnik Date: Fri, 13 Oct 2023 10:27:01 +0200 Subject: [PATCH] [meta] Remove serialize check for static arrays in structs (#1912) This will prevent to emmit dead code and will not give compiler warning from gcc >= 12.2 --- meta/serialize.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/meta/serialize.pm b/meta/serialize.pm index 9da9b9c4b..f81383ca8 100644 --- a/meta/serialize.pm +++ b/meta/serialize.pm @@ -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}; @@ -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";