Skip to content

Commit 034c475

Browse files
committed
Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors. * Add NOLINT for implicit conversion constructors. * Fix also some misaligned indendations. Bug: 28341362 Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e Test: build with clang-tidy
1 parent 02ccdc5 commit 034c475

34 files changed

+56
-56
lines changed

debuggerd/test/BacktraceMock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class BacktraceMapMock : public BacktraceMap {
4141

4242
class BacktraceMock : public Backtrace {
4343
public:
44-
BacktraceMock(BacktraceMapMock* map) : Backtrace(0, 0, map) {
44+
explicit BacktraceMock(BacktraceMapMock* map) : Backtrace(0, 0, map) {
4545
if (map_ == nullptr) {
4646
abort();
4747
}

fastboot/socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Socket {
104104

105105
protected:
106106
// Protected constructor to force factory function use.
107-
Socket(cutils_socket_t sock);
107+
explicit Socket(cutils_socket_t sock);
108108

109109
// Blocks up to |timeout_ms| until a read is possible on |sock_|, and sets |receive_timed_out_|
110110
// as appropriate to help distinguish between normal timeouts and fatal errors. Returns true if

init/action.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Command {
4444

4545
class Action {
4646
public:
47-
Action(bool oneshot = false);
47+
explicit Action(bool oneshot = false);
4848

4949
bool AddCommand(const std::vector<std::string>& args,
5050
const std::string& filename, int line, std::string* err);

init/parser/tokenizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace init {
3636
// a TOK_NEWLINE will not be generated for that line.
3737
class Tokenizer {
3838
public:
39-
Tokenizer(const std::string& data);
39+
explicit Tokenizer(const std::string& data);
4040
~Tokenizer();
4141

4242
enum TokenType { TOK_START, TOK_END, TOK_NEWLINE, TOK_TEXT };

libbacktrace/UnwindMap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
class UnwindMap : public BacktraceMap {
3131
public:
32-
UnwindMap(pid_t pid);
32+
explicit UnwindMap(pid_t pid);
3333

3434
unw_map_cursor_t* GetMapCursor() { return &map_cursor_; }
3535

@@ -39,7 +39,7 @@ class UnwindMap : public BacktraceMap {
3939

4040
class UnwindMapRemote : public UnwindMap {
4141
public:
42-
UnwindMapRemote(pid_t pid);
42+
explicit UnwindMapRemote(pid_t pid);
4343
virtual ~UnwindMapRemote();
4444

4545
bool Build() override;

liblog/tests/benchmark.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Benchmark {
3838
Benchmark(const char* name, void (*fn)(int)) : name_(strdup(name)), fn_(fn) {
3939
BenchmarkRegister(this);
4040
}
41-
Benchmark(const char* name) : name_(strdup(name)), fn_(NULL) {}
41+
explicit Benchmark(const char* name) : name_(strdup(name)), fn_(NULL) {}
4242

4343
virtual ~Benchmark() {
4444
free(name_);

libmemunreachable/Allocator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ class STLAllocator {
109109
}
110110

111111
// Construct an STLAllocator on top of a Heap
112-
STLAllocator(const Heap& heap) :
112+
STLAllocator(const Heap& heap) : // NOLINT, implicit
113113
heap_(heap) {
114114
}
115115

116116
// Rebind an STLAllocator from an another STLAllocator
117117
template<typename U>
118-
STLAllocator(const STLAllocator<U>& other) :
118+
STLAllocator(const STLAllocator<U>& other) : // NOLINT, implicit
119119
heap_(other.heap_) {
120120
}
121121

@@ -155,12 +155,12 @@ class Allocator : public STLAllocator<T> {
155155
public:
156156
~Allocator() {}
157157

158-
Allocator(const Heap& other) :
158+
Allocator(const Heap& other) : // NOLINT, implicit
159159
STLAllocator<T>(other) {
160160
}
161161

162162
template<typename U>
163-
Allocator(const STLAllocator<U>& other) :
163+
Allocator(const STLAllocator<U>& other) : // NOLINT, implicit
164164
STLAllocator<T>(other) {
165165
}
166166

libmemunreachable/HeapWalker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct compare_range {
4848

4949
class HeapWalker {
5050
public:
51-
HeapWalker(Allocator<HeapWalker> allocator) : allocator_(allocator),
51+
explicit HeapWalker(Allocator<HeapWalker> allocator) : allocator_(allocator),
5252
allocations_(allocator), allocation_bytes_(0),
5353
roots_(allocator), root_vals_(allocator),
5454
segv_handler_(allocator), walking_ptr_(0) {

libmemunreachable/LeakFolding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class LeakFolding {
5454
bool dominator;
5555
SCCInfo* accumulator;
5656

57-
SCCInfo(Allocator<SCCInfo> allocator) : node(this, allocator),
57+
explicit SCCInfo(Allocator<SCCInfo> allocator) : node(this, allocator),
5858
count(0), size(0), cuumulative_count(0), cuumulative_size(0),
5959
dominator(false), accumulator(nullptr) {}
6060
private:

libmemunreachable/LinkedList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ template<class T>
2121
class LinkedList {
2222
public:
2323
LinkedList() : next_(this), prev_(this), data_() {}
24-
LinkedList(T data) : LinkedList() {
24+
explicit LinkedList(T data) : LinkedList() {
2525
data_ = data;
2626
}
2727
~LinkedList() {}

libmemunreachable/PtracerThread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Stack;
3232
// the parent.
3333
class PtracerThread {
3434
public:
35-
PtracerThread(const std::function<int()>& func);
35+
explicit PtracerThread(const std::function<int()>& func);
3636
~PtracerThread();
3737
bool Start();
3838
int Join();

libmemunreachable/ScopedDisableMalloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ScopedDisableMalloc {
7474

7575
class ScopedDisableMallocTimeout {
7676
public:
77-
ScopedDisableMallocTimeout(std::chrono::milliseconds timeout = std::chrono::milliseconds(2000)) :
77+
explicit ScopedDisableMallocTimeout(std::chrono::milliseconds timeout = std::chrono::milliseconds(2000)) :
7878
timeout_(timeout), timed_out_(false), disable_malloc_() {
7979
Disable();
8080
}

libmemunreachable/ScopedSignalHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ScopedSignalHandler {
3030
public:
3131
using Fn = std::function<void(ScopedSignalHandler&, int, siginfo_t*, void*)>;
3232

33-
ScopedSignalHandler(Allocator<Fn> allocator) : allocator_(allocator), signal_(-1) {}
33+
explicit ScopedSignalHandler(Allocator<Fn> allocator) : allocator_(allocator), signal_(-1) {}
3434
~ScopedSignalHandler() {
3535
reset();
3636
}

libmemunreachable/Semaphore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
class Semaphore {
2626
public:
27-
Semaphore(int count = 0) : count_(count) {}
27+
explicit Semaphore(int count = 0) : count_(count) {}
2828
~Semaphore() = default;
2929

3030
void Wait(std::chrono::milliseconds ms) {

libmemunreachable/Tarjan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ using SCCList = allocator::vector<SCC<T>>;
6262
template<class T>
6363
class TarjanAlgorithm {
6464
public:
65-
TarjanAlgorithm(Allocator<void> allocator) : index_(0),
65+
explicit TarjanAlgorithm(Allocator<void> allocator) : index_(0),
6666
stack_(allocator), components_(allocator) {}
6767

6868
void Execute(Graph<T>& graph, SCCList<T>& out);

libmemunreachable/tests/MemUnreachable_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void* ptr;
2727

2828
class HiddenPointer {
2929
public:
30-
HiddenPointer(size_t size = 256) {
30+
explicit HiddenPointer(size_t size = 256) {
3131
Set(malloc(size));
3232
}
3333
~HiddenPointer() {

libpixelflinger/codeflinger/ARMAssembler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace android {
3535
class ARMAssembler : public ARMAssemblerInterface
3636
{
3737
public:
38-
ARMAssembler(const sp<Assembly>& assembly);
38+
explicit ARMAssembler(const sp<Assembly>& assembly);
3939
virtual ~ARMAssembler();
4040

4141
uint32_t* base() const;

libpixelflinger/codeflinger/ARMAssemblerProxy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ARMAssemblerProxy : public ARMAssemblerInterface
3434
// ARMAssemblerProxy take ownership of the target
3535

3636
ARMAssemblerProxy();
37-
ARMAssemblerProxy(ARMAssemblerInterface* target);
37+
explicit ARMAssemblerProxy(ARMAssemblerInterface* target);
3838
virtual ~ARMAssemblerProxy();
3939

4040
void setTarget(ARMAssemblerInterface* target);

libpixelflinger/codeflinger/Arm64Assembler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ namespace android {
4747
class ArmToArm64Assembler : public ARMAssemblerInterface
4848
{
4949
public:
50-
ArmToArm64Assembler(const sp<Assembly>& assembly);
51-
ArmToArm64Assembler(void *base);
50+
explicit ArmToArm64Assembler(const sp<Assembly>& assembly);
51+
explicit ArmToArm64Assembler(void *base);
5252
virtual ~ArmToArm64Assembler();
5353

5454
uint32_t* base() const;

libpixelflinger/codeflinger/CodeCache.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ template <typename T>
4242
class AssemblyKey : public AssemblyKeyBase
4343
{
4444
public:
45-
AssemblyKey(const T& rhs) : mKey(rhs) { }
45+
explicit AssemblyKey(const T& rhs) : mKey(rhs) { }
4646
virtual int compare_type(const AssemblyKeyBase& key) const {
4747
const T& rhs = static_cast<const AssemblyKey&>(key).mKey;
4848
return android::compare_type(mKey, rhs);
@@ -56,7 +56,7 @@ class AssemblyKey : public AssemblyKeyBase
5656
class Assembly
5757
{
5858
public:
59-
Assembly(size_t size);
59+
explicit Assembly(size_t size);
6060
virtual ~Assembly();
6161

6262
ssize_t size() const;
@@ -80,13 +80,13 @@ class CodeCache
8080
{
8181
public:
8282
// pretty simple cache API...
83-
CodeCache(size_t size);
84-
~CodeCache();
85-
86-
sp<Assembly> lookup(const AssemblyKeyBase& key) const;
83+
explicit CodeCache(size_t size);
84+
~CodeCache();
8785

88-
int cache( const AssemblyKeyBase& key,
89-
const sp<Assembly>& assembly);
86+
sp<Assembly> lookup(const AssemblyKeyBase& key) const;
87+
88+
int cache(const AssemblyKeyBase& key,
89+
const sp<Assembly>& assembly);
9090

9191
private:
9292
// nothing to see here...
@@ -105,7 +105,7 @@ class CodeCache
105105
const AssemblyKeyBase* mKey;
106106
public:
107107
key_t() { };
108-
key_t(const AssemblyKeyBase& k) : mKey(&k) { }
108+
explicit key_t(const AssemblyKeyBase& k) : mKey(&k) { }
109109
};
110110

111111
mutable pthread_mutex_t mLock;

libpixelflinger/codeflinger/GGLAssembler.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class RegisterAllocator
4949
public:
5050
class RegisterFile;
5151

52-
RegisterAllocator(int arch);
52+
RegisterAllocator(int arch); // NOLINT, implicit
5353
RegisterFile& registerFile();
5454
int reserveReg(int reg);
5555
int obtainReg();
@@ -59,7 +59,7 @@ class RegisterAllocator
5959
class RegisterFile
6060
{
6161
public:
62-
RegisterFile(int arch);
62+
RegisterFile(int arch); // NOLINT, implicit
6363
RegisterFile(const RegisterFile& rhs, int arch);
6464
~RegisterFile();
6565

@@ -101,7 +101,7 @@ class RegisterAllocator
101101
class Scratch
102102
{
103103
public:
104-
Scratch(RegisterFile& regFile)
104+
explicit Scratch(RegisterFile& regFile)
105105
: mRegFile(regFile), mScratch(0) {
106106
}
107107
~Scratch() {
@@ -177,8 +177,8 @@ class GGLAssembler : public ARMAssemblerProxy, public RegisterAllocator
177177
{
178178
public:
179179

180-
GGLAssembler(ARMAssemblerInterface* target);
181-
virtual ~GGLAssembler();
180+
explicit GGLAssembler(ARMAssemblerInterface* target);
181+
virtual ~GGLAssembler();
182182

183183
uint32_t* base() const { return 0; } // XXX
184184
uint32_t* pc() const { return 0; } // XXX
@@ -206,7 +206,7 @@ class GGLAssembler : public ARMAssemblerProxy, public RegisterAllocator
206206
struct reg_t {
207207
reg_t() : reg(-1), flags(0) {
208208
}
209-
reg_t(int r, int f=0)
209+
reg_t(int r, int f=0) // NOLINT, implicit
210210
: reg(r), flags(f) {
211211
}
212212
void setTo(int r, int f=0) {
@@ -219,7 +219,7 @@ class GGLAssembler : public ARMAssemblerProxy, public RegisterAllocator
219219
struct integer_t : public reg_t {
220220
integer_t() : reg_t(), s(0) {
221221
}
222-
integer_t(int r, int sz=32, int f=0)
222+
integer_t(int r, int sz=32, int f=0) // NOLINT, implicit
223223
: reg_t(r, f), s(sz) {
224224
}
225225
void setTo(int r, int sz=32, int f=0) {
@@ -251,7 +251,7 @@ class GGLAssembler : public ARMAssemblerProxy, public RegisterAllocator
251251
struct component_t : public reg_t {
252252
component_t() : reg_t(), h(0), l(0) {
253253
}
254-
component_t(int r, int f=0)
254+
component_t(int r, int f=0) // NOLINT, implicit
255255
: reg_t(r, f), h(0), l(0) {
256256
}
257257
component_t(int r, int lo, int hi, int f=0)

libpixelflinger/codeflinger/tinyutils/smartpointer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ class sp
5151
public:
5252
inline sp() : m_ptr(0) { }
5353

54-
sp(T* other);
54+
sp(T* other); // NOLINT, implicit
5555
sp(const sp<T>& other);
56-
template<typename U> sp(U* other);
57-
template<typename U> sp(const sp<U>& other);
56+
template<typename U> sp(U* other); // NOLINT, implicit
57+
template<typename U> sp(const sp<U>& other); // NOLINT, implicit
5858

5959
~sp();
6060

libutils/tests/Looper_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class StubCallbackHandler : public CallbackHandler {
7676
int fd;
7777
int events;
7878

79-
StubCallbackHandler(int nextResult) : nextResult(nextResult),
79+
explicit StubCallbackHandler(int nextResult) : nextResult(nextResult),
8080
callbackCount(0), fd(-1), events(-1) {
8181
}
8282

libutils/tests/StrongPointer_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using namespace android;
2323

2424
class Foo : public LightRefBase<Foo> {
2525
public:
26-
Foo(bool* deleted_check) : mDeleted(deleted_check) {
26+
explicit Foo(bool* deleted_check) : mDeleted(deleted_check) {
2727
*mDeleted = false;
2828
}
2929

libutils/tests/TestHelpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class DelayedTask : public Thread {
6060
int mDelayMillis;
6161

6262
public:
63-
DelayedTask(int delayMillis) : mDelayMillis(delayMillis) { }
63+
explicit DelayedTask(int delayMillis) : mDelayMillis(delayMillis) { }
6464

6565
protected:
6666
virtual ~DelayedTask() { }

logd/FlushCommand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class FlushCommand : public SocketClientCommand {
3535
uint64_t mTimeout;
3636

3737
public:
38-
FlushCommand(LogReader &mReader,
38+
explicit FlushCommand(LogReader &mReader,
3939
bool nonBlock = false,
4040
unsigned long tail = -1,
4141
unsigned int logMask = -1,

logd/LogBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class LogBuffer {
103103
public:
104104
LastLogTimes &mTimes;
105105

106-
LogBuffer(LastLogTimes *times);
106+
explicit LogBuffer(LastLogTimes *times);
107107
void init();
108108
bool isMonotonic() { return monotonic; }
109109

logd/LogCommand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
class LogCommand : public FrameworkCommand {
2424
public:
25-
LogCommand(const char *cmd);
25+
explicit LogCommand(const char *cmd);
2626
virtual ~LogCommand() {}
2727
};
2828

logd/LogReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class LogReader : public SocketListener {
2727
LogBuffer &mLogbuf;
2828

2929
public:
30-
LogReader(LogBuffer *logbuf);
30+
explicit LogReader(LogBuffer *logbuf);
3131
void notifyNewLog();
3232

3333
LogBuffer &logbuf(void) const { return mLogbuf; }

0 commit comments

Comments
 (0)