dist, dev: fix etherswitch upgrade script
authorCurtis Dunham <Curtis.Dunham@arm.com>
Mon, 19 Dec 2016 18:12:28 +0000 (12:12 -0600)
committerCurtis Dunham <Curtis.Dunham@arm.com>
Mon, 19 Dec 2016 18:12:28 +0000 (12:12 -0600)
The aforementioned upgrader in [1] assumes every option in [system]
has a delimiting '.', and also seems to do its rewriting work a bit too
unconditionally.  Most checkpoints in the wild don't have this device,
in which case this script should be a safe no-op.

[1] 2aa4d7b  dist, dev: Fixed the packet ordering in etherswitch

Change-Id: Icfd0350985109df1628eb9ab864cda42c54060a8
Reviewed-by: Gabor Dozsa <gabor.dozsa@arm.com>
util/cpt_upgraders/etherswitch.py

index e4094f97d3202be037b7949d41beb87356f3d4fd..9cd82a2d0fc0a70de09b7e272b3ecbe005e701a7 100644 (file)
@@ -4,18 +4,19 @@ def upgrader(cpt):
             options = cpt.items(sec)
             for it in options:
                 opt_split = it[0].split('.')
+                if len(opt_split) < 2: continue
                 new_sec_name = opt_split[1]
                 old_opt_name = opt_split[len(opt_split) - 1]
                 if "outputFifo" in new_sec_name:
                     new_sec_name = new_sec_name.rstrip("outputFifo")
                     new_sec_name += ".outputFifo"
-                new_sec_name = "system.system.%s" %(new_sec_name)
-                if not cpt.has_section(new_sec_name):
-                    cpt.add_section(new_sec_name)
-                if old_opt_name == "size":
-                    cpt.set(new_sec_name, "_size", it[1])
-                elif old_opt_name == "packets":
-                    cpt.set(new_sec_name, "fifosize", it[1])
-                else:
-                    cpt.set(new_sec_name, old_opt_name, it[1])
-                cpt.remove_option(sec, it[0])
+                    new_sec_name = "system.system.%s" %(new_sec_name)
+                    if not cpt.has_section(new_sec_name):
+                        cpt.add_section(new_sec_name)
+                    if old_opt_name == "size":
+                        cpt.set(new_sec_name, "_size", it[1])
+                    elif old_opt_name == "packets":
+                        cpt.set(new_sec_name, "fifosize", it[1])
+                    else:
+                        cpt.set(new_sec_name, old_opt_name, it[1])
+                    cpt.remove_option(sec, it[0])