Synced from resonance-engine-active - July 16 2026
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fix extra closing brace before cmd_result == 9 dispatch."""
|
||||
path = '/mnt/d/resonance-engine-active/cuda/khra_gixx_1024_v5_observer.cu'
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# Find the problem: line with " }" followed by blank then " } else if (cmd_result == 9) {"
|
||||
# We need to remove the extra " }" line that closes the if-else chain prematurely
|
||||
# and de-indent the next line to continue the chain
|
||||
|
||||
for i, line in enumerate(lines):
|
||||
# Find: health_check_pending = 1; } [extra }] } else if (cmd_result == 9)
|
||||
if 'health_check_pending = 1;' in line:
|
||||
# Next line should be " }" (closing the cmd_result==8 block)
|
||||
# Then empty line ""
|
||||
# Then " } else if (cmd_result == 9) {" <-- this extra } is wrong
|
||||
# Fix: remove the empty line and the extra }, then change next line to " } else if (cmd_result == 9) {"
|
||||
for j in range(i+1, min(i+5, len(lines))):
|
||||
if ' } else if (cmd_result == 9) {' in lines[j]:
|
||||
# This is the line with the extra brace
|
||||
# Change it to be a proper else-if continuation
|
||||
lines[j] = ' } else if (cmd_result == 9) {\n'
|
||||
print(f"Fixed line {j+1}: removed extra brace, de-indented")
|
||||
break
|
||||
break
|
||||
|
||||
# Also need to remove any stray empty line + brace between cmd_result 8 and the ack section
|
||||
# Let me find and clean up the structure
|
||||
|
||||
for i, line in enumerate(lines):
|
||||
if ' } else if (cmd_result == 9) {' in line:
|
||||
# Make sure there's no " }" line before this (except the one closing cmd_result 8)
|
||||
for j in range(i-1, max(i-5, 0), -1):
|
||||
stripped = lines[j].strip()
|
||||
if stripped == '}':
|
||||
if 'cmd_result' not in lines[j]:
|
||||
# This is a stray closing brace — remove it
|
||||
lines[j] = ''
|
||||
print(f"Removed stray brace at line {j+1}")
|
||||
elif stripped == '':
|
||||
continue
|
||||
else:
|
||||
break
|
||||
break
|
||||
|
||||
with open(path, 'w', encoding='utf-8') as f:
|
||||
f.writelines(lines)
|
||||
|
||||
print("Fix applied. Verifying structure...")
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check that cmd_result == 9 is properly in the if-else chain
|
||||
if ' } else if (cmd_result == 9) {' in content:
|
||||
print("[OK] cmd_result == 9 is properly inside if-else chain")
|
||||
else:
|
||||
print("[WARN] cmd_result == 9 pattern not found with expected indentation")
|
||||
|
||||
# Verify no double-brace pattern
|
||||
import re
|
||||
matches = re.findall(r'\} else if.*\{', content[content.find('cmd_result == 8')-200:content.find('cmd_result == 9')+50])
|
||||
print(f"Struct in region: found {len(matches)} } else if patterns")
|
||||
for m in matches:
|
||||
print(f" {m[:80]}")
|
||||
Reference in New Issue
Block a user