Upgrade AIO::path String to SBuf - #2463
Conversation
kinkie
left a comment
There was a problem hiding this comment.
One comment; apart from that LGTM
rousskov
left a comment
There was a problem hiding this comment.
All change requests are about out-of-scope PR changes.
Please do not post new non-emergency PRs until the backlog problem is solved.
| AIODiskIOStrategy *strategy; | ||
| int fd = -1; | ||
| SBuf path; | ||
| AIODiskIOStrategy *strategy = nullptr; |
There was a problem hiding this comment.
If this data member must be set by the class constructor, then it is best to leave it uninitialized here to avoid implying that some reasonable initial or default value exists:
| AIODiskIOStrategy *strategy = nullptr; | |
| AIODiskIOStrategy *strategy; |
There was a problem hiding this comment.
That practice being requested is a "bad practice".
Reason: The "undefined" value is completely random. Which means it may be a value within the application legitimately allocated memory and thus indistinguishable from a valid allocation when inspected by memory access checkers.
[ Given Squid memory pooling design, the allocation will be from a previously allocated object of the same type, meaning a high chance that the pointed to memory would have the structure of a legitimate (but not valid) strategy object. ]
Solution: Explicitly initialize to a value which is guaranteed to be outside accessible memory ranges. The value nullptr, NULL, or 0 are traditionally used for this.
Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
Also, C++11 initialize the class to simplify constructor.