Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Issue 774933011: Made sizeof code simpler and more obviously correct. (Closed)

Created:
6 years ago by brucedawson
Modified:
6 years ago
CC:
chromium-reviews, erikwright+watch_chromium.org, jshin+watch_chromium.org, rvargas (doing something else), Markus (顧孟勤)
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Made 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1 line, -1 line) Patch
M base/strings/safe_sprintf_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 7 (2 generated)
brucedawson
6 years ago (2014-12-05 00:36:02 UTC) #2
jln (very slow on Chromium)
Wow, this code was weird. lgtm
6 years ago (2014-12-05 02:09:05 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/774933011/1
6 years ago (2014-12-05 18:35:44 UTC) #5
commit-bot: I haz the power
Committed patchset #1 (id:1)
6 years ago (2014-12-05 19:13:18 UTC) #6
commit-bot: I haz the power
6 years ago (2014-12-05 19:14:57 UTC) #7
Message was sent while issue was closed.
Patchset 1 (id:??) landed as
https://crrev.com/5b7c43227cca038cc4cbcb11fbb5d889fdd3a49f
Cr-Commit-Position: refs/heads/master@{#307054}

Powered by Google App Engine
This is Rietveld 408576698