Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ngc_flowctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,11 @@ FLASHMEM static void stack_unwind_sub (uint32_t o_label)
FLASHMEM void ngc_flowctrl_unwind_stack (vfs_file_t *file)
{
clear_subs(file);
while(stack_idx >= 0 && stack[stack_idx].file == file)
while(stack_idx >= 0 && stack[stack_idx].file == file) {
if(stack[stack_idx].o_label > NGC_MAX_PARAM_ID)
stream_redirect_close(stack[stack_idx].file);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates file close elsewhere in the code (pre call) and is not needed/may cause issues.

stack_pull();
}
}

FLASHMEM static status_code_t onGcodeComment (char *comment)
Expand Down Expand Up @@ -358,8 +361,15 @@ FLASHMEM void ngc_flowctrl_init (void)
}

clear_subs(NULL);
while(stack_idx >= 0)
// Close any still-open named-subroutine file redirect before dropping this stack entry - a Reset
// landing mid-O-call previously left hal.stream.read permanently stuck on the file reader
// (stream_file.c's stream_read_file), since this loop only cleared the stack's own bookkeeping.
// Mirrors stack_unwind_sub()'s handling of the same entry kind.
Comment on lines +364 to +367

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO comments like this should be in the PR conversation, not here. If a comment is warranted it should be short and concise.

while(stack_idx >= 0) {
if(stack[stack_idx].o_label > NGC_MAX_PARAM_ID)
stream_redirect_close(stack[stack_idx].file);
stack_pull();
}
}

// NOTE: onNamedSubError will be called recursively for each
Expand Down