Skip to content

Commit 1a22147

Browse files
committed
Prefer no std:: prefixes on integer types
Specifically for `size_t` from `stddef.h` and `uint*_t`/`int*_t` types from `stdint.h`. Per the style guide: https://google.github.io/styleguide/cppguide.html#Integer_Types Also, `Include What You Use` updates: https://google.github.io/styleguide/cppguide.html#Include_What_You_Use Bug: 484413551
1 parent a5bfeea commit 1a22147

101 files changed

Lines changed: 658 additions & 531 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/cvd/cuttlefish/common/libs/concurrency/thread_safe_queue.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#pragma once
2-
31
/*
42
* Copyright (C) 2016 The Android Open Source Project
53
*
@@ -16,6 +14,10 @@
1614
* limitations under the License.
1715
*/
1816

17+
#pragma once
18+
19+
#include <stddef.h>
20+
1921
#include <condition_variable>
2022
#include <deque>
2123
#include <functional>
@@ -38,7 +40,7 @@ class ThreadSafeQueue {
3840
using QueueFullHandler = std::function<void(QueueImpl*)>;
3941

4042
ThreadSafeQueue() = default;
41-
explicit ThreadSafeQueue(std::size_t max_elements,
43+
explicit ThreadSafeQueue(size_t max_elements,
4244
QueueFullHandler max_elements_handler)
4345
: max_elements_{max_elements},
4446
max_elements_handler_{std::move(max_elements_handler)} {}
@@ -99,7 +101,7 @@ class ThreadSafeQueue {
99101
}
100102

101103
std::mutex m_;
102-
std::size_t max_elements_{};
104+
size_t max_elements_{};
103105
QueueFullHandler max_elements_handler_{};
104106
std::condition_variable new_item_;
105107
QueueImpl items_;

base/cvd/cuttlefish/common/libs/confui/packet.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
#include "cuttlefish/common/libs/confui/packet.h"
1717

18+
#include <stdint.h>
19+
1820
#include <algorithm>
19-
#include <cstdint>
2021
#include <optional>
2122
#include <string>
2223
#include <vector>
@@ -26,7 +27,7 @@
2627
namespace cuttlefish {
2728
namespace confui {
2829
namespace packet {
29-
static std::optional<std::vector<std::uint8_t>> ReadRawData(SharedFD s) {
30+
static std::optional<std::vector<uint8_t>> ReadRawData(SharedFD s) {
3031
if (!s->IsOpen()) {
3132
ConfUiLog(ERROR) << "file, socket, etc, is not open to read";
3233
return std::nullopt;
@@ -56,13 +57,13 @@ static std::optional<std::vector<std::uint8_t>> ReadRawData(SharedFD s) {
5657
ConfUiLog(ERROR) << "The length ReadRawData read does not match.";
5758
return std::nullopt;
5859
}
59-
std::vector<std::uint8_t> result{buf.get(), buf.get() + nread};
60+
std::vector<uint8_t> result{buf.get(), buf.get() + nread};
6061

6162
return {result};
6263
}
6364

6465
static std::optional<ParsedPacket> ParseRawData(
65-
const std::vector<std::uint8_t>& data_to_parse) {
66+
const std::vector<uint8_t>& data_to_parse) {
6667
/*
6768
* data_to_parse has 0 in it, so it is not exactly "your (text) std::string."
6869
* If we type-cast data_to_parse to std::string and use 3rd party std::string-
@@ -133,7 +134,7 @@ static std::optional<ParsedPacket> ParseRawData(
133134
if (len == 0) {
134135
// push null vector or whatever empty, appropriately-typed
135136
// container
136-
data_to_return.emplace_back(std::vector<std::uint8_t>{});
137+
data_to_return.emplace_back(std::vector<uint8_t>{});
137138
continue;
138139
}
139140
data_to_return.emplace_back(data_to_parse.begin() + pos,

base/cvd/cuttlefish/common/libs/confui/packet.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
#pragma once
1717

18+
#include <stdint.h>
19+
1820
#include <algorithm>
19-
#include <cstdint>
2021
#include <optional>
2122
#include <string>
2223
#include <tuple>
@@ -91,7 +92,7 @@ Payload ToPayload(const std::string& cmd_str, const std::string& session_id,
9192
ss << sz << ":";
9293
}
9394
std::string header = ss.str();
94-
std::vector<std::uint8_t> payload_buffer{header.begin(), header.end()};
95+
std::vector<uint8_t> payload_buffer{header.begin(), header.end()};
9596
impl::AppendToBuffer(payload_buffer, std::forward<Args>(args)...);
9697

9798
PayloadHeader ph;

base/cvd/cuttlefish/common/libs/confui/packet_types.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
#pragma once
1717

18-
#include <cstdint>
18+
#include <stdint.h>
19+
1920
#include <sstream>
2021
#include <string>
2122
#include <tuple>
@@ -25,18 +26,18 @@ namespace cuttlefish {
2526
namespace confui {
2627
namespace packet {
2728
struct PayloadHeader {
28-
std::uint32_t payload_length_;
29+
uint32_t payload_length_;
2930
};
3031

31-
using BufferType = std::vector<std::uint8_t>;
32+
using BufferType = std::vector<uint8_t>;
3233

3334
// PayloadHeader + the byte size sent over the channel
3435
using Payload = std::tuple<PayloadHeader, BufferType>;
3536

3637
// this is for short messages
3738
constexpr const ssize_t kMaxPayloadLength = 10000;
3839

39-
using ConfUiPacketInfo = std::vector<std::vector<std::uint8_t>>;
40+
using ConfUiPacketInfo = std::vector<std::vector<uint8_t>>;
4041
struct ParsedPacket {
4142
std::string session_id_;
4243
std::string type_;

base/cvd/cuttlefish/common/libs/confui/protocol.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include "cuttlefish/common/libs/confui/protocol.h"
1717

18+
#include <stdint.h>
19+
1820
#include <sstream>
1921
#include <vector>
2022

@@ -132,16 +134,16 @@ bool SendAck(SharedFD fd, const std::string& session_id, const bool is_success,
132134

133135
bool SendResponse(SharedFD fd, const std::string& session_id,
134136
const UserResponse::type& plain_selection,
135-
const std::vector<std::uint8_t>& signed_response,
136-
const std::vector<std::uint8_t>& message) {
137+
const std::vector<uint8_t>& signed_response,
138+
const std::vector<uint8_t>& message) {
137139
ConfUiCliResponseMessage confui_msg{session_id, plain_selection,
138140
signed_response, message};
139141
return confui_msg.SendOver(fd);
140142
}
141143

142144
bool SendStartCmd(SharedFD fd, const std::string& session_id,
143145
const std::string& prompt_text,
144-
const std::vector<std::uint8_t>& extra_data,
146+
const std::vector<uint8_t>& extra_data,
145147
const std::string& locale,
146148
const std::vector<teeui::UIOption>& ui_opts) {
147149
ConfUiStartMessage confui_msg{session_id, prompt_text, extra_data, locale,

base/cvd/cuttlefish/common/libs/confui/protocol.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
#pragma once
1717

18-
#include <cstdint>
18+
#include <stdint.h>
19+
1920
#include <memory>
2021
#include <string>
2122
#include <vector>
@@ -49,14 +50,14 @@ bool SendAck(SharedFD fd, const std::string& session_id, const bool is_success,
4950
const std::string& status_message);
5051
bool SendResponse(SharedFD fd, const std::string& session_id,
5152
const UserResponse::type& plain_selection,
52-
const std::vector<std::uint8_t>& signed_response,
53+
const std::vector<uint8_t>& signed_response,
5354
// signing is a function of message, key
54-
const std::vector<std::uint8_t>& message);
55+
const std::vector<uint8_t>& message);
5556

5657
// for HAL
5758
bool SendStartCmd(SharedFD fd, const std::string& session_id,
5859
const std::string& prompt_text,
59-
const std::vector<std::uint8_t>& extra_data,
60+
const std::vector<uint8_t>& extra_data,
6061
const std::string& locale,
6162
const std::vector<teeui::UIOption>& ui_opts);
6263

base/cvd/cuttlefish/common/libs/confui/protocol_types.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
#include "cuttlefish/common/libs/confui/protocol_types.h"
1717

18-
#include <cstdint>
18+
#include <stdint.h>
19+
1920
#include <map>
2021
#include <sstream>
2122
#include <unordered_map>
@@ -51,7 +52,7 @@ std::string ToDebugString(const ConfUiCmd& cmd, const bool is_verbose) {
5152

5253
std::string ToString(const ConfUiCmd& cmd) { return ToDebugString(cmd, false); }
5354

54-
ConfUiCmd ToCmd(std::uint32_t i) {
55+
ConfUiCmd ToCmd(uint32_t i) {
5556
std::vector<ConfUiCmd> all_cmds{
5657
ConfUiCmd::kStart, ConfUiCmd::kStop,
5758
ConfUiCmd::kCliAck, ConfUiCmd::kCliRespond,

base/cvd/cuttlefish/common/libs/confui/protocol_types.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
#pragma once
1717

18-
#include <cstdint>
18+
#include <stdint.h>
19+
1920
#include <string>
2021
#include <utility>
2122
#include <vector>
@@ -32,7 +33,7 @@ namespace cuttlefish {
3233
namespace confui {
3334
// When you update this, please update all the utility functions
3435
// in conf.cpp: e.g. ToString, etc
35-
enum class ConfUiCmd : std::uint32_t {
36+
enum class ConfUiCmd : uint32_t {
3637
kUnknown = 100,
3738
kStart = 111, // start rendering, send confirmation msg, & wait respond
3839
kStop = 112, // start rendering, send confirmation msg, & wait respond
@@ -49,7 +50,7 @@ constexpr const ssize_t kMaxMessageLength = packet::kMaxPayloadLength;
4950
std::string ToString(const ConfUiCmd& cmd);
5051
std::string ToDebugString(const ConfUiCmd& cmd, const bool is_verbose);
5152
ConfUiCmd ToCmd(const std::string& cmd_str);
52-
ConfUiCmd ToCmd(std::uint32_t i);
53+
ConfUiCmd ToCmd(uint32_t i);
5354

5455
std::string ToString(const teeui::UIOption ui_opt);
5556
std::optional<teeui::UIOption> ToUiOption(const std::string&);
@@ -136,8 +137,8 @@ class ConfUiCliResponseMessage : public ConfUiMessage {
136137
public:
137138
ConfUiCliResponseMessage(const std::string& session_id,
138139
const UserResponse::type& response,
139-
const std::vector<std::uint8_t>& sign = {},
140-
const std::vector<std::uint8_t>& msg = {})
140+
const std::vector<uint8_t>& sign = {},
141+
const std::vector<uint8_t>& msg = {})
141142
: ConfUiMessage(session_id),
142143
response_(response),
143144
sign_(sign),
@@ -152,16 +153,16 @@ class ConfUiCliResponseMessage : public ConfUiMessage {
152153

153154
private:
154155
UserResponse::type response_; // plain format
155-
std::vector<std::uint8_t> sign_; // signed format
156+
std::vector<uint8_t> sign_; // signed format
156157
// second argument to pass via resultCB of promptUserConfirmation
157-
std::vector<std::uint8_t> message_;
158+
std::vector<uint8_t> message_;
158159
};
159160

160161
class ConfUiStartMessage : public ConfUiMessage {
161162
public:
162163
ConfUiStartMessage(const std::string session_id,
163164
const std::string& prompt_text = "",
164-
const std::vector<std::uint8_t>& extra_data = {},
165+
const std::vector<uint8_t>& extra_data = {},
165166
const std::string& locale = "C",
166167
const std::vector<teeui::UIOption> ui_opts = {})
167168
: ConfUiMessage(session_id),
@@ -173,14 +174,14 @@ class ConfUiStartMessage : public ConfUiMessage {
173174
std::string ToString() const override;
174175
ConfUiCmd GetType() const override { return ConfUiCmd::kStart; }
175176
std::string GetPromptText() const { return prompt_text_; }
176-
std::vector<std::uint8_t> GetExtraData() const { return extra_data_; }
177+
std::vector<uint8_t> GetExtraData() const { return extra_data_; }
177178
std::string GetLocale() const { return locale_; }
178179
std::vector<teeui::UIOption> GetUiOpts() const { return ui_opts_; }
179180
bool SendOver(SharedFD fd) override;
180181

181182
private:
182183
std::string prompt_text_;
183-
std::vector<std::uint8_t> extra_data_;
184+
std::vector<uint8_t> extra_data_;
184185
std::string locale_;
185186
std::vector<teeui::UIOption> ui_opts_;
186187

base/cvd/cuttlefish/common/libs/fs/shared_fd_stream.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "cuttlefish/common/libs/fs/shared_fd_stream.h"
1818

19+
#include <stddef.h>
20+
1921
#include <cstdio>
2022
#include <streambuf>
2123

@@ -87,7 +89,7 @@ int SharedFDStreambuf::overflow(int c) {
8789
std::streamsize SharedFDStreambuf::xsputn(const char* source,
8890
std::streamsize count) {
8991
return static_cast<std::streamsize>(
90-
WriteAll(shared_fd_, source, static_cast<std::size_t>(count)));
92+
WriteAll(shared_fd_, source, static_cast<size_t>(count)));
9193
}
9294

9395
int SharedFDStreambuf::pbackfail(int c) {

base/cvd/cuttlefish/common/libs/security/confui_sign.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
#include "cuttlefish/common/libs/security/confui_sign.h"
1818

19-
#include <cstdint>
19+
#include <stdint.h>
20+
2021
#include <optional>
2122
#include <vector>
2223

@@ -25,7 +26,7 @@
2526
namespace cuttlefish {
2627
bool ConfUiSignerImpl::Send(SharedFD output,
2728
const confui::SignMessageError error,
28-
const std::vector<std::uint8_t>& payload) {
29+
const std::vector<uint8_t>& payload) {
2930
#define SET_FLAG_AND_RETURN_SEND \
3031
sign_status_ |= kIoError; \
3132
return false
@@ -75,7 +76,7 @@ std::optional<confui::SignRawMessage> ConfUiSignerImpl::Receive(
7576
return std::nullopt;
7677
}
7778

78-
std::vector<std::uint8_t> buffer(payload_size);
79+
std::vector<uint8_t> buffer(payload_size);
7980
char* buf_data = reinterpret_cast<char*>(buffer.data());
8081
n_read = ReadExact(input, buf_data, payload_size);
8182
if (n_read != payload_size) {
@@ -91,15 +92,15 @@ std::optional<confui::SignRawMessage> ConfUiSignSender::Receive() {
9192
}
9293

9394
bool ConfUiSignSender::Send(const SignMessageError error,
94-
const std::vector<std::uint8_t>& encoded_hmac) {
95+
const std::vector<uint8_t>& encoded_hmac) {
9596
if (!impl_.IsOk()) {
9697
return false;
9798
}
9899
impl_.Send(server_fd_, error, encoded_hmac);
99100
return impl_.IsOk();
100101
}
101102

102-
bool ConfUiSignRequester::Request(const std::vector<std::uint8_t>& message) {
103+
bool ConfUiSignRequester::Request(const std::vector<uint8_t>& message) {
103104
impl_.Send(client_fd_, confui::SignMessageError::kOk, message);
104105
return impl_.IsOk();
105106
}

0 commit comments

Comments
 (0)