Skip to content

Commit 4ef461e

Browse files
committed
account for chanigng function index when reordering, clean logging
Signed-off-by: Zen <[email protected]>
1 parent 8b6443e commit 4ef461e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ugrd/initramfs_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ def iter_order(order, direction):
177177

178178
def reorder_func(direction):
179179
"""Reorders the function based on the direction."""
180-
self.logger.debug("Moving %s %s %s" % (func_name, direction, other_func))
181180
if direction == "before": # Move the function before the other function
182181
self.logger.debug("[%s] Moving function before: %s" % (func_name, other_func))
183182
func_names.insert(other_index, func_names.pop(func_index))
@@ -204,6 +203,7 @@ def reorder_func(direction):
204203
self.logger.log(5, "Function %s already after: %s" % (func_name, other_func))
205204
else:
206205
raise ValueError("Invalid direction: %s" % direction)
206+
func_index = func_names.index(func_name) # Update the index after moving
207207
return changed
208208

209209
max_iterations = len(func_names) * (len(before) + 1) * (len(after) + 1) # Prevent infinite loops

0 commit comments

Comments
 (0)