mmap failure [was: cygrunsrv + sshd + rsync = 20 times too slow -- throttled?]

Sam Edge sam.edge.cygwin@gmx.com
Wed Sep 8 06:14:45 GMT 2021


On 07/09/2021 23:44, Ken Brown via Cygwin wrote:
 >
 > MS can't add a new named field to a documented struct without
breaking a lot of code.  I think it's extremely unlikely that they would
do that.  On the other hand, I think it's very likely that a reader of
the Cygwin code would be confused by code that initializes a struct to 0
prior to assigning a value to every member.

Hi Ken.

It is common practice when following a coding standard (especially those
for safety or security sensitive code) to initialize each and every
automatic C/C++ variable at the point of definition even if it is later
assigned a value. The '= {0}' mechanism for structures is a common way
of ensuring this is the case for all fields in a structure and should be
familiar to most developers.

This ensures deterministic behaviour instead of bugs that come and go
depending upon what was on the stack or in the register before the
variable is used. It also helps when reviewing code.

A compiler or static analyser cannot always determine whether a variable
is used before it's assigned so getting into the habit of doing this
saves a lot of grief down the line, as demonstrated by this thread!

--
Sam "Here Endeth The Lesson" Edge


More information about the Cygwin mailing list