tools: ynl: fix get_mask utility routine
authorLorenzo Bianconi <lorenzo@kernel.org>
Thu, 9 Mar 2023 12:25:26 +0000 (13:25 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 11 Mar 2023 05:33:47 +0000 (21:33 -0800)
Fix get_mask utility routine in order to take into account possible gaps
in the elements list.

Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/net/ynl/lib/nlspec.py

index a34d088f67432187c0d5b0e457788081d1ba5f95..960a356e8225e63360a820b6e9f7230e2986e3e0 100644 (file)
@@ -138,10 +138,8 @@ class SpecEnumSet(SpecElement):
 
     def get_mask(self):
         mask = 0
-        idx = self.yaml.get('value-start', 0)
-        for _ in self.entries.values():
-            mask |= 1 << idx
-            idx += 1
+        for e in self.entries.values():
+            mask += e.user_value()
         return mask