DescriptionMade sizeof code simpler and more obviously correct.
VC++'s /analyze complained about peculiar use of sizeof, and the code is
peculiar.
The original code was:
memset(ref, 'X', sizeof(char) * arraysize(buf));
Validating the correctness of this requires knowing that buf and ref
have the same number of elements, and requires knowing that ref is an
array of 'char'. It is simpler and safer to do this:
memset(ref, 'X', sizeof(ref));
The warning was:
src\base\strings\safe_sprintf_unittest.cc(64) : warning C6260:
sizeof * sizeof is usually wrong. Did you intend to use a character count
or a byte count?
This change will not change the behavior of the code, just its
readability.
This code was introduced in:
https://chromiumcodereview.appspot.com/18656004
BUG=427616
Committed: https://crrev.com/5b7c43227cca038cc4cbcb11fbb5d889fdd3a49f
Cr-Commit-Position: refs/heads/master@{#307054}
Patch Set 1 #
Messages
Total messages: 7 (2 generated)
|