DPDK patches and discussions
 help / color / mirror / Atom feed
* Coding Style for local variables
@ 2024-06-10 15:10 Morten Brørup
  2024-06-10 16:11 ` Tyler Retzlaff
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Morten Brørup @ 2024-06-10 15:10 UTC (permalink / raw)
  To: dev

The coding style guide says:

"Variables should be declared at the start of a block of code rather than in the middle. The exception to this is when the variable is const in which case the declaration must be at the point of first use/assignment. Declaring variable inside a for loop is OK."

Since DPDK switched to C11, variables can be declared where they are used, which reduces the risk of using effectively uninitialized variables. "Effectively uninitialized" means initialized to 0 or NULL where declared, to silence any compiler warnings about the use of uninitialized variables.

Can we please agree to remove the recommendation/requirement to declare variables at the start of a block of code?


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-06-20 14:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-10 15:10 Coding Style for local variables Morten Brørup
2024-06-10 16:11 ` Tyler Retzlaff
2024-06-10 16:31 ` Konstantin Ananyev
2024-06-20  0:38   ` Thomas Monjalon
2024-06-20  7:53     ` Morten Brørup
2024-06-20  8:09       ` Konstantin Ananyev
2024-06-20  9:02         ` Morten Brørup
2024-06-20 14:45           ` Stephen Hemminger
2024-06-11 15:10 ` Ferruh Yigit
2024-06-11 15:50   ` Stephen Hemminger
2024-06-17 14:38 ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).