aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-10-25 07:57:30 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2016-10-25 15:24:06 +0000
commitaf0c70cf764f7b027102b7e5e89f8c34436b5f22 (patch)
tree7ee7abcef6806ba21660a44f5a6f428500b218fb
parent5b3808ed633248fd304b9790c719665081ba7a2b (diff)
Improve equals generation for jvpp DTOs
Variable 'other' is no longer defined in equals method of DTOs without defined fileds. Fixes dead local store coverity issues. Change-Id: I69eddf2b4b3f433149ff4d49e49c46515572d61a Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--vpp-api/java/jvpp/gen/jvppgen/dto_gen.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py b/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
index b117288cdd2..12354793bf7 100644
--- a/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
+++ b/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
@@ -150,7 +150,9 @@ def generate_dto_tostring(camel_case_dto_name, func):
return tostring_template.substitute(cls_name=camel_case_dto_name,
fields_tostring=tostring_fields[:-8])
-
+equals_other_template = Template("""
+ final $cls_name other = ($cls_name) o;
+\n""")
equals_field_template = Template(""" if (!java.util.Objects.equals(this.$field_name, other.$field_name)) {
return false;
}\n""")
@@ -165,9 +167,6 @@ equals_template = Template(""" @Override
if (o == null || getClass() != o.getClass()) {
return false;
}
-
- final $cls_name other = ($cls_name) o;
-
$comparisons
return true;
}\n\n""")
@@ -187,8 +186,10 @@ def generate_dto_equals(camel_case_dto_name, func):
else:
equals_fields += equals_field_template.substitute(field_name=field_name)
- return equals_template.substitute(cls_name=camel_case_dto_name,
- comparisons=equals_fields)
+ if equals_fields != "":
+ equals_fields = equals_other_template.substitute(cls_name=camel_case_dto_name) + equals_fields
+
+ return equals_template.substitute(comparisons=equals_fields)
hash_template = Template(""" @Override