You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time I'm puzzled for a few seconds why somebody is creating an array and casting it in the next line to void. I assume the array created in line 46 is cast to void in line 47 in order to circumvent a compiler warning about an unused variable. The warning is probably triggered when the code is compiled with logging disabled or set to a higher level than TRACE (in this example).
One solution is to create "boiler plate" code which checks the log level beforehand, e.g.
The downside (besides the boiler plate) is that the debug_level variable is not thread-safe which is at this point is not a concern, but could cause problems in versions of CCN-lite which should be thread-safe (a discussion we've already had).
Another option would be to put these kind of debug statements into an extra function (which would reduce the boiler plate code). Question is if there are enough DEBUGMSG statements which look like the above (or other examples)?
Any thoughts about it?
The text was updated successfully, but these errors were encountered:
We should improve the quality of the code of the ccn-lite logging mechanism. While browsing the code, I often read code like the following
Every time I'm puzzled for a few seconds why somebody is creating an array and casting it in the next line to
void
. I assume the array created in line 46 is cast tovoid
in line 47 in order to circumvent a compiler warning about an unused variable. The warning is probably triggered when the code is compiled with logging disabled or set to a higher level thanTRACE
(in this example).One solution is to create "boiler plate" code which checks the log level beforehand, e.g.
The downside (besides the boiler plate) is that the
debug_level
variable is not thread-safe which is at this point is not a concern, but could cause problems in versions of CCN-lite which should be thread-safe (a discussion we've already had).Another option would be to put these kind of debug statements into an extra function (which would reduce the boiler plate code). Question is if there are enough
DEBUGMSG
statements which look like the above (or other examples)?Any thoughts about it?
The text was updated successfully, but these errors were encountered: