Scope of variables flagged by code inspector
zack leung
zakthertemsdev at gmail.com
Sun Oct 10 18:25:30 UTC 2021
Hello,
I recently was invited to look at a new code review tool by Joel. It's used
to help with reducing technical debt. It suggests various fixes and
highlights various possible errors. One of them relates to the fact that
some of the variable scopes and be reduced. For example, we can define
variables when they are needed not at the beginning of functions. I don't
know if it matters much. Maybe it helps with memory due to the timing of
things allocated on the stack. This also helps with the compiler not
needing to analyze long lifespans. This also prevents the variable to be
flagged as uninitialized.
But personally, I feel it's easier to read if we don't change where
variables are defined. An example of this is found in
testsuites/mptests/mp09/task1.c. An array called recieve_Buffer could be
defined later. I'm not sure if this matters much. I want to know your
input.
Zack
More information about the devel
mailing list