tools: ynl: store ops in ordered dict to avoid random ordering
authorJakub Kicinski <kuba@kernel.org>
Thu, 26 Jan 2023 00:02:35 +0000 (16:02 -0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 27 Jan 2023 00:32:41 +0000 (16:32 -0800)
When rendering code we should walk the ops in the order in which
they are declared in the spec. This is both more intuitive and
prevents code from jumping around when hashing in the dict changes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/net/ynl/ynl-gen-c.py

index 9297cfa..1aa872e 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 
 import argparse
+import collections
 import jsonschema
 import os
 import yaml
@@ -793,7 +794,7 @@ class Family:
         # list of all operations
         self.msg_list = []
         # dict of operations which have their own message type (have attributes)
-        self.ops = dict()
+        self.ops = collections.OrderedDict()
         self.attr_sets = dict()
         self.attr_sets_list = []