// SAFETY: CommandLineToArgvW returns an array of size num_args.
auto argv_span =
UNSAFE_TODO(base::span(argv.get(), static_cast<size_t>(num_args)));
std::wstring recreated_command_line;
for (int i = 1; i < num_args; ++i) {
recreated_command_line.append(
CommandLine::QuoteForCommandLineToArgvW(argv_span[i]));let's just use UNSAFE_TODO here, without trying to rewrite code, or add SAFETY comments.
// |found_address_struct->sdl_data| contains the interface name followed
// by the interface address. The address part can be accessed based on
// the length of the name, that is, |found_address_struct->sdl_nlen|.
base::span<const unsigned char> address_span = UNSAFE_TODO(
base::span(reinterpret_cast<const unsigned char*>(
&found_address_struct
->sdl_data[found_address_struct->sdl_nlen]),
static_cast<size_t>(found_address_struct->sdl_alen)));
for (size_t i = 0; i < address_span.size(); ++i) {
if (i != 0) {
mac_string.push_back(':');
}
base::StringAppendF(&mac_string, "%02X", address_span[i]);
}
break;
}Here, let's not try to improve code. Just use the original code with UNSAFE_TODO where needed.
bool IsRunningOnOrLater(const std::array<int32_t, 3>& version) const {
for (size_t i = 0; i < current_version_.size(); ++i) {
if (current_version_[i] != version[i]) {
return current_version_[i] > version[i];
}
}
return true;
}
private:
std::array<int32_t, 3> current_version_;
} kOSVersion;
std::array<int32_t, 3> version = {major, minor, bug_fix};
return kOSVersion.IsRunningOnOrLater(version);Here, let's just use UNSAFE_TODO where needed and revert the changes to the code.
// Use of this source code is governed by a BSD-style license that can beLet's revert this file.
// found in the LICENSE file.Let's revert this file.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
for (int i = 1; i < num_args; ++i) {
recreated_command_line.append(
CommandLine::QuoteForCommandLineToArgvW(UNSAFE_TODO(argv.get()[i])));
if (i + 1 < num_args) {
recreated_command_line.push_back(L' ');
}
}Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// by the interface address. The address part can be accessed based on
// the length of the name, that is, |found_address_struct->sdl_nlen|.
const unsigned char* found_address =
reinterpret_cast<const unsigned char*>(
UNSAFE_TODO(&found_address_struct
->sdl_data[found_address_struct->sdl_nlen]));
int found_address_length = found_address_struct->sdl_alen;
for (int i = 0; i < found_address_length; ++i) {
if (i != 0) {
mac_string.push_back(':');
}
base::StringAppendF(&mac_string, "%02X",
UNSAFE_TODO(found_address[i]));
}
break;
} for (size_t i = 0; i < std::size(current_version_); ++i) {
if (UNSAFE_TODO(current_version_[i]) != UNSAFE_TODO(version[i])) {
return UNSAFE_TODO(current_version_[i]) > UNSAFE_TODO(version[i]);
}
}
return true;
}
private:
int32_t current_version_[3];
} kOSVersion;
int32_t version[3] = {major, minor, bug_fix};
return kOSVersion.IsRunningOnOrLater(version);
}// Use of this source code is governed by a BSD-style license that can beLet's revert this file.
Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// found in the LICENSE file.Arthur SonzogniLet's revert this file.
Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
| Code-Review | +1 |
This looks good to me.
@dch...@chromium.org, could you please take take a look.
(Note that it contains two std::array rewrite along the way)
// SAFETY: CommandLineToArgvW returns an array of size num_args.
auto argv_span =
UNSAFE_TODO(base::span(argv.get(), static_cast<size_t>(num_args)));
std::wstring recreated_command_line;
for (int i = 1; i < num_args; ++i) {
recreated_command_line.append(
CommandLine::QuoteForCommandLineToArgvW(argv_span[i]));let's just use UNSAFE_TODO here, without trying to rewrite code, or add SAFETY comments.
Acknowledged
// |found_address_struct->sdl_data| contains the interface name followed
// by the interface address. The address part can be accessed based on
// the length of the name, that is, |found_address_struct->sdl_nlen|.
base::span<const unsigned char> address_span = UNSAFE_TODO(
base::span(reinterpret_cast<const unsigned char*>(
&found_address_struct
->sdl_data[found_address_struct->sdl_nlen]),
static_cast<size_t>(found_address_struct->sdl_alen)));
for (size_t i = 0; i < address_span.size(); ++i) {
if (i != 0) {
mac_string.push_back(':');
}
base::StringAppendF(&mac_string, "%02X", address_span[i]);
}
break;
}Arthur SonzogniHere, let's not try to improve code. Just use the original code with UNSAFE_TODO where needed.
Acknowledged
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
LGTM
return modes[static_cast<size_t>(mode_index_)];Though it would be nice to avoid the cast here by using the correct type to begin with.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +2 |
Thanks!
return modes[static_cast<size_t>(mode_index_)];Though it would be nice to avoid the cast here by using the correct type to begin with.
I am planning a follow-up.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[unsafe-buffers] Remove allow_unsafe_buffers from base/
This is a mechanical change transitioning the last few files in base/
from coarse, file-level pragmas to fine-grained, instruction-level
UNSAFE_TODO() macros.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |