From 82adc1d585a086b5ed77f8e253a56c1aff41d1ee Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Sun, 15 May 2022 02:14:30 +0200 Subject: [PATCH] [WIP MSG] fix the side effects --- common/generate_packets.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/common/generate_packets.py b/common/generate_packets.py index 60655fa47b..0c99411cb1 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -437,13 +437,20 @@ class Field: } }'''%self.get_dict(vars()) + @property + def folded_into_head(self): + return ( + fold_bool_into_header + and self.struct_type == "bool" + and not self.is_array + ) + # Returns a code fragment which updates the bit of the this field # in the "fields" bitvector. The bit is either a "content-differs" # bit or (for bools which gets folded in the header) the actual # value of the bool. def get_cmp_wrapper(self, i, pack): - if fold_bool_into_header and self.struct_type=="bool" and \ - not self.is_array: + if self.folded_into_head: if pack.is_info != "no": cmp = self.get_cmp() differ_part = ''' @@ -471,7 +478,6 @@ class Field: '''%(cmp, i) else: - pack.differ_used = True return '''%s if (differ) { BV_SET(fields, %d); @@ -979,7 +985,17 @@ class Variant: self.type=packet.type self.delta=packet.delta self.is_info=packet.is_info - self.differ_used = False + self.differ_used = ( + (not self.no_packet) + and self.delta + and ( + self.is_info != "no" + or any( + not field.folded_into_head + for field in self.fields + ) + ) + ) self.cancel=packet.cancel self.want_force=packet.want_force @@ -1194,8 +1210,6 @@ static char *stats_%(name)s_names[] = {%(names)s}; %(name)s_fields fields; struct %(packet_name)s *old; ''' - if self.is_info != "no": - self.differ_used = True delta_header2 = ''' struct genhash **hash = pc->phs.sent + %(type)s; ''' if self.is_info != "no": -- 2.17.1