Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're going to touch this now, can we move the declaration to the beginning of the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this part of our style guide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW in the past the main justification for the preference for all variables to be declared at the beginning of the function was to track stack usage by the function.
This was of particular interest inside kernels where you may be working with a limited per-proces kernel stack. But, we aren't a kernel and this isn't even some large array of data (which still might warrant being at the top of the function for same reasons). Rather it's a temporary variable with recognizable limited scope so I actually think it's in the right place as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thought that this was a common FRR practice/convention, so I've often applied it in reviews (and my own FRR code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe should say a little more there: I like that the convention helps avoid shadowing problems, and helps avoid endless nitpicking about where exactly declarations should appear (once the box is opened).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chris just keeps the location as-is in this commit, and it's fixing a build failure on newer compiler versions that some people already reported. So I'd like to merge it now and not wait for another CI cycle.
I personally like the current version, because it defines a value in a limited scope, uses it immediately and removes. I think it makes more sense than defining it at the top. Anyway, we can decide on the general convention separately and fix this and other similar definitions separately if needed.