-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zebra: fix compiler warning about truncation. #15248
zebra: fix compiler warning about truncation. #15248
Conversation
Signed-off-by: Christian Hopps <[email protected]>
b0e1a72
to
a403a71
Compare
@@ -230,11 +230,12 @@ DEFUN_YANG_NOSH (link_params, | |||
|
|||
ret = nb_cli_apply_changes(vty, NULL); | |||
if (ret == CMD_SUCCESS) { | |||
char xpath[XPATH_MAXLEN]; | |||
char *xpath; |
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.
No description provided.