Skip to content

Commit adbc4f7

Browse files
alanzhao1Chromium LUCI CQ
authored andcommitted
Silence upcoming -Wunsafe-buffer-usage warnings
An upcoming Clang change (llvm/llvm-project#91991) makes -Wunsafe-buffer-usage warn on member initializers and member initializer list, so this patch silences those warnings. Bug: 377326291 Change-Id: I74206f5675f64f4f754793cff2bdb388ef8965cf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6002984 Code-Coverage: [email protected] <[email protected]> Reviewed-by: Nico Weber <[email protected]> Commit-Queue: Nico Weber <[email protected]> Owners-Override: Nico Weber <[email protected]> Cr-Commit-Position: refs/heads/main@{#1380096}
1 parent 6ec51fa commit adbc4f7

File tree

18 files changed

+72
-27
lines changed

18 files changed

+72
-27
lines changed

cc/paint/path_effect.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Copyright 2024 The Chromium Authors
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4+
#ifdef UNSAFE_BUFFERS_BUILD
5+
// TODO(crbug.com/377326291): Remove this and convert code to safer constructs.
6+
#pragma allow_unsafe_buffers
7+
#endif
48

59
#include "cc/paint/path_effect.h"
610

chrome/browser/sync_file_system/drive_backend/sync_task_manager_unittest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class BlockerUpdateTestHelper : public SyncTask {
230230
Log* log)
231231
: name_(name),
232232
app_id_(app_id),
233-
paths_(paths.begin(), paths.end()),
233+
paths_(base::from_range, paths),
234234
log_(log) {}
235235

236236
BlockerUpdateTestHelper(const BlockerUpdateTestHelper&) = delete;

chrome/updater/device_management/dm_policy_builder_for_testing.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#ifdef UNSAFE_BUFFERS_BUILD
6+
// TODO(crbug.com/377326291): Remove this and convert code to safer constructs.
7+
#pragma allow_unsafe_buffers
8+
#endif
9+
510
#include "chrome/updater/device_management/dm_policy_builder_for_testing.h"
611

712
#include <stdint.h>

content/browser/media/midi_host_unittest.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <stddef.h>
88
#include <stdint.h>
99

10+
#include "base/containers/to_vector.h"
1011
#include "base/memory/weak_ptr.h"
1112
#include "base/run_loop.h"
1213
#include "base/strings/stringprintf.h"
@@ -133,7 +134,7 @@ class MidiSessionClientForTesting : public midi::mojom::MidiSessionClient {
133134

134135
class MidiHostTest : public testing::Test {
135136
public:
136-
MidiHostTest() : data_(kNoteOn, kNoteOn + std::size(kNoteOn)), port_id_(0) {
137+
MidiHostTest() : data_(base::ToVector(kNoteOn)), port_id_(0) {
137138
browser_context_ = std::make_unique<TestBrowserContext>();
138139
rph_ = std::make_unique<MockRenderProcessHost>(browser_context_.get());
139140
std::unique_ptr<FakeMidiManagerFactory> factory =

content/browser/renderer_host/frame_tree.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "base/memory/safe_ref.h"
2121
#include "base/not_fatal_until.h"
2222
#include "base/ranges/algorithm.h"
23+
#include "base/ranges/from_range.h"
2324
#include "base/trace_event/optional_trace_event.h"
2425
#include "base/trace_event/typed_macros.h"
2526
#include "base/unguessable_token.h"
@@ -148,7 +149,7 @@ FrameTree::NodeIterator::NodeIterator(
148149
should_descend_into_inner_trees_(should_descend_into_inner_trees),
149150
include_delegate_nodes_for_inner_frame_trees_(
150151
include_delegate_nodes_for_inner_frame_trees),
151-
queue_(starting_nodes.begin(), starting_nodes.end()) {
152+
queue_(base::from_range, starting_nodes) {
152153
// If `include_delegate_nodes_for_inner_frame_trees_` is true then
153154
// `should_descend_into_inner_trees_` must be true.
154155
DCHECK(!include_delegate_nodes_for_inner_frame_trees_ ||

content/browser/service_worker/service_worker_new_script_loader.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#ifdef UNSAFE_BUFFERS_BUILD
6+
// TODO(crbug.com/377326291): Remove this and convert code to safer constructs.
7+
#pragma allow_unsafe_buffers
8+
#endif
9+
510
#include "content/browser/service_worker/service_worker_new_script_loader.h"
611

712
#include <memory>

content/browser/service_worker/service_worker_single_script_update_checker.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#ifdef UNSAFE_BUFFERS_BUILD
6+
// TODO(crbug.com/377326291): Remove this and convert code to safer constructs.
7+
#pragma allow_unsafe_buffers
8+
#endif
9+
510
#include "content/browser/service_worker/service_worker_single_script_update_checker.h"
611

712
#include <utility>

device/gamepad/dualshock4_controller_unittest.cc

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <memory>
88

9+
#include "base/containers/to_vector.h"
910
#include "base/functional/bind.h"
1011
#include "base/memory/raw_ptr.h"
1112
#include "base/memory/weak_ptr.h"
@@ -110,16 +111,10 @@ class FakeHidWriter : public HidWriter {
110111
class Dualshock4ControllerTest : public testing::Test {
111112
public:
112113
Dualshock4ControllerTest()
113-
: usb_start_vibration_report_(kUsbStartVibration,
114-
kUsbStartVibration + kUsbReportLength),
115-
usb_stop_vibration_report_(kUsbStopVibration,
116-
kUsbStopVibration + kUsbReportLength),
117-
bluetooth_start_vibration_report_(
118-
kBtStartVibration,
119-
kBtStartVibration + kBluetoothReportLength),
120-
bluetooth_stop_vibration_report_(
121-
kBtStopVibration,
122-
kBtStopVibration + kBluetoothReportLength),
114+
: usb_start_vibration_report_(base::ToVector(kUsbStartVibration)),
115+
usb_stop_vibration_report_(base::ToVector(kUsbStopVibration)),
116+
bluetooth_start_vibration_report_(base::ToVector(kBtStartVibration)),
117+
bluetooth_stop_vibration_report_(base::ToVector(kBtStopVibration)),
123118
callback_count_(0),
124119
callback_result_(
125120
mojom::GamepadHapticsResult::GamepadHapticsResultError) {

device/gamepad/hid_haptic_gamepad_unittest.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <memory>
88

9+
#include "base/containers/to_vector.h"
910
#include "base/functional/bind.h"
1011
#include "base/memory/raw_ptr.h"
1112
#include "base/memory/weak_ptr.h"
@@ -71,10 +72,8 @@ class FakeHidWriter : public HidWriter {
7172
class HidHapticGamepadTest : public testing::Test {
7273
public:
7374
HidHapticGamepadTest()
74-
: start_vibration_output_report_(kStartVibrationData,
75-
kStartVibrationData + kReportLength),
76-
stop_vibration_output_report_(kStopVibrationData,
77-
kStopVibrationData + kReportLength),
75+
: start_vibration_output_report_(base::ToVector(kStartVibrationData)),
76+
stop_vibration_output_report_(base::ToVector(kStopVibrationData)),
7877
first_callback_count_(0),
7978
second_callback_count_(0),
8079
first_callback_result_(

device/gamepad/xbox_hid_controller_unittest.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <memory>
88

9+
#include "base/containers/to_vector.h"
910
#include "base/functional/bind.h"
1011
#include "base/memory/raw_ptr.h"
1112
#include "base/memory/weak_ptr.h"
@@ -77,9 +78,8 @@ class FakeHidWriter : public HidWriter {
7778
class XboxHidControllerTest : public testing::Test {
7879
public:
7980
XboxHidControllerTest()
80-
: start_vibration_report_(kStartVibration,
81-
kStartVibration + kReportLength),
82-
stop_vibration_report_(kStopVibration, kStopVibration + kReportLength),
81+
: start_vibration_report_(base::ToVector(kStartVibration)),
82+
stop_vibration_report_(base::ToVector(kStopVibration)),
8383
callback_count_(0),
8484
callback_result_(
8585
mojom::GamepadHapticsResult::GamepadHapticsResultError) {

0 commit comments

Comments
 (0)