fix pointer style to match the style guide

We do this in a lot of places, but we're inconsistent.
Normalize the code to the Google C++ style guide.

Change-Id: Ic2aceab661ce8f6b993dda21b1cdf5d2198dcbbf
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2262932
Reviewed-by: Sterling Augustine <saugustine@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Mike Frysinger 2020-06-23 18:55:43 -04:00
parent a741027533
commit 09b056975d
289 changed files with 3770 additions and 3775 deletions

View file

@ -229,7 +229,7 @@ CrashGenerationServer::ClientEvent(short revents)
// Walk the control payload and extract the file descriptor and validated pid.
pid_t crashing_pid = -1;
int signal_fd = -1;
for (struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); hdr;
for (struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg); hdr;
hdr = CMSG_NXTHDR(&msg, hdr)) {
if (hdr->cmsg_level != SOL_SOCKET)
continue;
@ -248,7 +248,7 @@ CrashGenerationServer::ClientEvent(short revents)
signal_fd = reinterpret_cast<int*>(CMSG_DATA(hdr))[0];
}
} else if (hdr->cmsg_type == SCM_CREDENTIALS) {
const struct ucred *cred =
const struct ucred* cred =
reinterpret_cast<struct ucred*>(CMSG_DATA(hdr));
crashing_pid = cred->pid;
}
@ -324,7 +324,7 @@ CrashGenerationServer::MakeMinidumpFilename(string& outFilename)
// static
void*
CrashGenerationServer::ThreadMain(void *arg)
CrashGenerationServer::ThreadMain(void* arg)
{
reinterpret_cast<CrashGenerationServer*>(arg)->Run();
return NULL;

View file

@ -48,7 +48,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
return uc->uc_mcontext.gregs[REG_EIP];
}
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
const fpstate_t* fp) {
const greg_t* regs = uc->uc_mcontext.gregs;
@ -96,7 +96,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
return uc->uc_mcontext.gregs[REG_RIP];
}
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
const fpstate_t* fpregs) {
const greg_t* regs = uc->uc_mcontext.gregs;
@ -153,7 +153,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
return uc->uc_mcontext.arm_pc;
}
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc) {
out->context_flags = MD_CONTEXT_ARM_FULL;
out->iregs[0] = uc->uc_mcontext.arm_r0;
@ -192,7 +192,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
return uc->uc_mcontext.pc;
}
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
const struct fpsimd_context* fpregs) {
out->context_flags = MD_CONTEXT_ARM64_FULL_OLD;
@ -218,7 +218,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
return uc->uc_mcontext.pc;
}
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc) {
#if _MIPS_SIM == _ABI64
out->context_flags = MD_CONTEXT_MIPS64_FULL;
#elif _MIPS_SIM == _ABIO32

View file

@ -50,13 +50,13 @@ struct UContextReader {
// out: the minidump structure
// info: the collection of register structures.
#if defined(__i386__) || defined(__x86_64)
static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
const fpstate_t* fp);
#elif defined(__aarch64__)
static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
const struct fpsimd_context* fpregs);
#else
static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc);
static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc);
#endif
};

View file

@ -419,8 +419,8 @@ struct ThreadArgument {
// This is the entry function for the cloned process. We are in a compromised
// context here: see the top of the file.
// static
int ExceptionHandler::ThreadEntry(void *arg) {
const ThreadArgument *thread_arg = reinterpret_cast<ThreadArgument*>(arg);
int ExceptionHandler::ThreadEntry(void* arg) {
const ThreadArgument* thread_arg = reinterpret_cast<ThreadArgument*>(arg);
// Close the write end of the pipe. This allows us to fail if the parent dies
// while waiting for the continue signal.
@ -495,7 +495,7 @@ bool ExceptionHandler::SimulateSignalDelivery(int sig) {
}
// This function may run in a compromised context: see the top of the file.
bool ExceptionHandler::GenerateDump(CrashContext *context) {
bool ExceptionHandler::GenerateDump(CrashContext* context) {
if (IsOutOfProcess())
return crash_generation_client_->RequestDump(context, sizeof(*context));

View file

@ -82,7 +82,7 @@ class ExceptionHandler {
// attempting to write a minidump. If a FilterCallback returns false,
// Breakpad will immediately report the exception as unhandled without
// writing a minidump, allowing another handler the opportunity to handle it.
typedef bool (*FilterCallback)(void *context);
typedef bool (*FilterCallback)(void* context);
// A callback function to run after the minidump has been written.
// |descriptor| contains the file descriptor or file path containing the
@ -234,7 +234,7 @@ class ExceptionHandler {
static void RestoreHandlersLocked();
void PreresolveSymbols();
bool GenerateDump(CrashContext *context);
bool GenerateDump(CrashContext* context);
void SendContinueSignalToChild();
void WaitForContinueSignal();

View file

@ -201,7 +201,7 @@ static bool DoneCallback(const MinidumpDescriptor& descriptor,
// optimize them out. In the case of ExceptionHandlerTest::ExternalDumper,
// GCC-4.9 optimized out the entire set up of ExceptionHandler, causing
// test failure.
volatile int *p_null; // external linkage, so GCC can't tell that it
volatile int* p_null; // external linkage, so GCC can't tell that it
// remains NULL. Volatile just for a good measure.
static void DoNullPointerDereference() {
*p_null = 1;
@ -994,7 +994,7 @@ CrashHandler(const void* crash_context, size_t crash_context_size,
msg.msg_control = cmsg;
msg.msg_controllen = sizeof(cmsg);
struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg);
struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg);
hdr->cmsg_level = SOL_SOCKET;
hdr->cmsg_type = SCM_RIGHTS;
hdr->cmsg_len = CMSG_LEN(sizeof(int));
@ -1003,7 +1003,7 @@ CrashHandler(const void* crash_context, size_t crash_context_size,
hdr->cmsg_level = SOL_SOCKET;
hdr->cmsg_type = SCM_CREDENTIALS;
hdr->cmsg_len = CMSG_LEN(sizeof(struct ucred));
struct ucred *cred = reinterpret_cast<struct ucred*>(CMSG_DATA(hdr));
struct ucred* cred = reinterpret_cast<struct ucred*>(CMSG_DATA(hdr));
cred->uid = getuid();
cred->gid = getgid();
cred->pid = getpid();
@ -1056,7 +1056,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) {
pid_t crashing_pid = -1;
int signal_fd = -1;
for (struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); hdr;
for (struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg); hdr;
hdr = CMSG_NXTHDR(&msg, hdr)) {
if (hdr->cmsg_level != SOL_SOCKET)
continue;
@ -1066,7 +1066,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) {
ASSERT_EQ(sizeof(int), len);
signal_fd = *(reinterpret_cast<int*>(CMSG_DATA(hdr)));
} else if (hdr->cmsg_type == SCM_CREDENTIALS) {
const struct ucred *cred =
const struct ucred* cred =
reinterpret_cast<struct ucred*>(CMSG_DATA(hdr));
crashing_pid = cred->pid;
}

View file

@ -44,8 +44,8 @@ namespace {
// __android_log_buf_write() is not exported in the NDK and is being used by
// dynamic runtime linking. Its declaration is taken from Android's
// system/core/include/log/log.h.
using AndroidLogBufferWriteFunc = int (*)(int bufID, int prio, const char *tag,
const char *text);
using AndroidLogBufferWriteFunc = int (*)(int bufID, int prio, const char* tag,
const char* text);
const int kAndroidCrashLogId = 4; // From LOG_ID_CRASH in log.h.
const char kAndroidLogTag[] = "google-breakpad";

View file

@ -47,7 +47,7 @@ typedef testing::Test DirectoryReaderTest;
TEST(DirectoryReaderTest, CompareResults) {
std::set<string> dent_set;
DIR *const dir = opendir("/proc/self");
DIR* const dir = opendir("/proc/self");
ASSERT_TRUE(dir != NULL);
struct dirent* dent;

View file

@ -61,7 +61,7 @@ class LineReader {
//
// One must call |PopLine| after this function, otherwise you'll continue to
// get the same line over and over.
bool GetNextLine(const char **line, unsigned *len) {
bool GetNextLine(const char** line, unsigned* len) {
for (;;) {
if (buf_used_ == 0 && hit_eof_)
return false;

View file

@ -59,7 +59,7 @@ TEST(LineReaderTest, EmptyFile) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
const char *line;
const char* line;
unsigned len;
ASSERT_FALSE(reader.GetNextLine(&line, &len));
}
@ -69,7 +69,7 @@ TEST(LineReaderTest, OneLineTerminated) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
const char *line;
const char* line;
unsigned int len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ((unsigned int)1, len);
@ -85,7 +85,7 @@ TEST(LineReaderTest, OneLine) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
const char *line;
const char* line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ((unsigned)1, len);
@ -101,7 +101,7 @@ TEST(LineReaderTest, TwoLinesTerminated) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
const char *line;
const char* line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ((unsigned)1, len);
@ -123,7 +123,7 @@ TEST(LineReaderTest, TwoLines) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
const char *line;
const char* line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ((unsigned)1, len);
@ -147,7 +147,7 @@ TEST(LineReaderTest, MaxLength) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
const char *line;
const char* line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ(sizeof(l), len);
@ -163,7 +163,7 @@ TEST(LineReaderTest, TooLong) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
const char *line;
const char* line;
unsigned len;
ASSERT_FALSE(reader.GetNextLine(&line, &len));
}

View file

@ -135,7 +135,7 @@ const size_t kHpageMask = (~(kHpageSize - 1));
// next is backed by some file.
// curr and next are contiguous.
// offset(next) == sizeof(curr)
void TryRecoverMappings(MappingInfo *curr, MappingInfo *next) {
void TryRecoverMappings(MappingInfo* curr, MappingInfo* next) {
// Merged segments are marked with size = 0.
if (curr->size == 0 || next->size == 0)
return;
@ -167,8 +167,8 @@ void TryRecoverMappings(MappingInfo *curr, MappingInfo *next) {
// next and prev are backed by the same file.
// prev, curr and next are contiguous.
// offset(next) == offset(prev) + sizeof(prev) + sizeof(curr)
void TryRecoverMappings(MappingInfo *prev, MappingInfo *curr,
MappingInfo *next) {
void TryRecoverMappings(MappingInfo* prev, MappingInfo* curr,
MappingInfo* next) {
// Merged segments are marked with size = 0.
if (prev->size == 0 || curr->size == 0 || next->size == 0)
return;
@ -551,11 +551,11 @@ bool LinuxDumper::EnumerateMappings() {
// See http://www.trilithium.com/johan/2005/08/linux-gate/ for more
// information.
const void* linux_gate_loc =
reinterpret_cast<void *>(auxv_[AT_SYSINFO_EHDR]);
reinterpret_cast<void*>(auxv_[AT_SYSINFO_EHDR]);
// Although the initial executable is usually the first mapping, it's not
// guaranteed (see http://crosbug.com/25355); therefore, try to use the
// actual entry point to find the mapping.
const void* entry_point_loc = reinterpret_cast<void *>(auxv_[AT_ENTRY]);
const void* entry_point_loc = reinterpret_cast<void*>(auxv_[AT_ENTRY]);
const int fd = sys_open(maps_path, O_RDONLY, 0);
if (fd < 0)

View file

@ -110,8 +110,8 @@ class LinuxDumper {
}
// These are only valid after a call to |Init|.
const wasteful_vector<pid_t> &threads() { return threads_; }
const wasteful_vector<MappingInfo*> &mappings() { return mappings_; }
const wasteful_vector<pid_t>& threads() { return threads_; }
const wasteful_vector<MappingInfo*>& mappings() { return mappings_; }
const MappingInfo* FindMapping(const void* address) const;
// Find the mapping which the given memory address falls in. Unlike
// FindMapping, this method uses the unadjusted mapping address

View file

@ -55,8 +55,8 @@
#error This test has not been ported to this platform.
#endif
void *thread_function(void *data) {
int pipefd = *static_cast<int *>(data);
void* thread_function(void* data) {
int pipefd = *static_cast<int*>(data);
volatile pid_t* thread_id = new pid_t;
*thread_id = syscall(__NR_gettid);
// Signal parent that a thread has started.
@ -65,13 +65,13 @@ void *thread_function(void *data) {
perror("ERROR: parent notification failed");
return NULL;
}
register volatile pid_t *thread_id_ptr asm(TID_PTR_REGISTER) = thread_id;
register volatile pid_t* thread_id_ptr asm(TID_PTR_REGISTER) = thread_id;
while (true)
asm volatile ("" : : "r" (thread_id_ptr));
return NULL;
}
int main(int argc, char *argv[]) {
int main(int argc, char* argv[]) {
if (argc < 3) {
fprintf(stderr,
"usage: linux_dumper_unittest_helper <pipe fd> <# of threads>\n");

View file

@ -337,7 +337,7 @@ TEST_F(LinuxPtraceDumperChildTest, MappingsIncludeLinuxGate) {
ASSERT_TRUE(dumper.Init());
void* linux_gate_loc =
reinterpret_cast<void *>(dumper.auxv()[AT_SYSINFO_EHDR]);
reinterpret_cast<void*>(dumper.auxv()[AT_SYSINFO_EHDR]);
ASSERT_TRUE(linux_gate_loc);
bool found_linux_gate = false;

View file

@ -740,14 +740,14 @@ class MinidumpWriter {
}
bool WriteDSODebugStream(MDRawDirectory* dirent) {
ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr) *>(dumper_->auxv()[AT_PHDR]);
ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(dumper_->auxv()[AT_PHDR]);
char* base;
int phnum = dumper_->auxv()[AT_PHNUM];
if (!phnum || !phdr)
return false;
// Assume the program base is at the beginning of the same page as the PHDR
base = reinterpret_cast<char *>(reinterpret_cast<uintptr_t>(phdr) & ~0xfff);
base = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(phdr) & ~0xfff);
// Search for the program PT_DYNAMIC segment
ElfW(Addr) dyn_addr = 0;
@ -768,7 +768,7 @@ class MinidumpWriter {
if (!dyn_addr)
return false;
ElfW(Dyn) *dynamic = reinterpret_cast<ElfW(Dyn) *>(dyn_addr + base);
ElfW(Dyn)* dynamic = reinterpret_cast<ElfW(Dyn)*>(dyn_addr + base);
// The dynamic linker makes information available that helps gdb find all
// DSOs loaded into the program. If this information is indeed available,
@ -1222,7 +1222,7 @@ class MinidumpWriter {
Buffers* next;
size_t len;
uint8_t data[kBufSize];
} *buffers = reinterpret_cast<Buffers*>(Alloc(sizeof(Buffers)));
}* buffers = reinterpret_cast<Buffers*>(Alloc(sizeof(Buffers)));
buffers->next = NULL;
buffers->len = 0;

View file

@ -299,10 +299,10 @@ TEST(MinidumpWriterTest, MinidumpStacksSkippedIfRequested) {
Minidump minidump(templ);
ASSERT_TRUE(minidump.Read());
MinidumpThreadList *threads = minidump.GetThreadList();
MinidumpThreadList* threads = minidump.GetThreadList();
int threads_with_stacks = 0;
for (unsigned int i = 0; i < threads->thread_count(); ++i) {
MinidumpThread *thread = threads->GetThreadAtIndex(i);
MinidumpThread* thread = threads->GetThreadAtIndex(i);
if (thread->GetMemory()) {
++threads_with_stacks;
}
@ -353,13 +353,13 @@ TEST(MinidumpWriterTest, StacksAreSanitizedIfRequested) {
#else
0x0defaced;
#endif
MinidumpThreadList *threads = minidump.GetThreadList();
MinidumpThreadList* threads = minidump.GetThreadList();
for (unsigned int i = 0; i < threads->thread_count(); ++i) {
MinidumpThread *thread = threads->GetThreadAtIndex(i);
MinidumpMemoryRegion *mem = thread->GetMemory();
MinidumpThread* thread = threads->GetThreadAtIndex(i);
MinidumpMemoryRegion* mem = thread->GetMemory();
ASSERT_TRUE(mem != nullptr);
uint32_t sz = mem->GetSize();
const uint8_t *data = mem->GetMemory();
const uint8_t* data = mem->GetMemory();
ASSERT_TRUE(memmem(data, sz, &defaced, sizeof(defaced)) != nullptr);
}
close(fds[1]);

View file

@ -41,7 +41,7 @@ namespace google_breakpad {
string GetHelperBinary() {
string helper_path;
char *bindir = getenv("bindir");
char* bindir = getenv("bindir");
if (bindir) {
helper_path = string(bindir) + "/";
} else {

View file

@ -65,7 +65,7 @@ TEST(ProcCpuInfoReaderTest, EmptyFile) {
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char *field;
const char* field;
ASSERT_FALSE(reader.GetNextField(&field));
}
@ -74,7 +74,7 @@ TEST(ProcCpuInfoReaderTest, OneLineTerminated) {
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char *field;
const char* field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
ASSERT_STREQ("bar", reader.GetValue());
@ -87,7 +87,7 @@ TEST(ProcCpuInfoReaderTest, OneLine) {
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
const char *field;
const char* field;
size_t value_len;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);

View file

@ -84,7 +84,7 @@ bool CheckForRequiredFlagsOrDie() {
return true;
}
int main(int argc, char *argv[]) {
int main(int argc, char* argv[]) {
google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, true);
if (!CheckForRequiredFlagsOrDie()) {