diff options
author | danakj <danakj@chromium.org> | 2024-05-02 10:21:37 -0700 |
---|---|---|
committer | chromeos-ci-prod <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com> | 2024-05-03 04:21:40 -0700 |
commit | 1a65c6dba425787edc2af6b65d55ceeb297cc12b (patch) | |
tree | 9cb1ef7e197a66cd8bb6e7566077a59eee1e74fd | |
parent | 0c63f229a2149007d930e44831b7767423875f23 (diff) | |
download | libchrome-1a65c6dba425787edc2af6b65d55ceeb297cc12b.tar.gz |
Spanify base::Crc32
Use std::array which is bounds checked instead of a native array.
R=thestig@chromium.org
Bug: 40284755
Change-Id: I936e8c2d443b31217e4c3bc231bbda6bbacbc38b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5508080
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1295563}
CrOS-Libchrome-Original-Commit: 074e6489d33d394ab53df75511a8f63b13ddb2ea
-rw-r--r-- | base/metrics/crc32.cc | 7 | ||||
-rw-r--r-- | base/metrics/crc32.h | 4 |
2 files changed, 4 insertions, 7 deletions
diff --git a/base/metrics/crc32.cc b/base/metrics/crc32.cc index 5708c6dc6b..5117f7ea3d 100644 --- a/base/metrics/crc32.cc +++ b/base/metrics/crc32.cc @@ -2,17 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifdef UNSAFE_BUFFERS_BUILD -// TODO(crbug.com/40284755): Remove this and spanify to fix the errors. -#pragma allow_unsafe_buffers -#endif - #include "base/metrics/crc32.h" namespace base { // Static table of checksums for all possible 8 bit bytes. -const uint32_t kCrcTable[256] = { +const std::array<uint32_t, 256> kCrcTable = { 0x0, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x76dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0xedb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x9b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, diff --git a/base/metrics/crc32.h b/base/metrics/crc32.h index 55fcb526c5..9e4e9134ef 100644 --- a/base/metrics/crc32.h +++ b/base/metrics/crc32.h @@ -8,12 +8,14 @@ #include <stddef.h> #include <stdint.h> +#include <array> + #include "base/base_export.h" #include "base/containers/span.h" namespace base { -BASE_EXPORT extern const uint32_t kCrcTable[256]; +BASE_EXPORT extern const std::array<uint32_t, 256> kCrcTable; // This provides a simple, fast CRC-32 calculation that can be used for checking // the integrity of data. It is not a "secure" calculation! |sum| can start |