Apply clang-format to all C, C++ and ObjC files (issue #2171)

This commit is contained in:
Marshall Greenblatt
2017-05-17 11:29:28 +02:00
parent a566549e04
commit 31d9407ee2
1331 changed files with 33014 additions and 32258 deletions

View File

@@ -20,26 +20,28 @@
// of the global offset table. To avoid breaking such executables, this code
// must preserve that register's value across cpuid instructions.
#if defined(__i386__)
#define cpuid(a, b, c, d, inp) \
asm("mov %%ebx, %%edi\n" \
"cpuid\n" \
"xchg %%edi, %%ebx\n" \
: "=a" (a), "=D" (b), "=c" (c), "=d" (d) : "a" (inp))
#define cpuid(a, b, c, d, inp) \
asm("mov %%ebx, %%edi\n" \
"cpuid\n" \
"xchg %%edi, %%ebx\n" \
: "=a"(a), "=D"(b), "=c"(c), "=d"(d) \
: "a"(inp))
#elif defined(__x86_64__)
#define cpuid(a, b, c, d, inp) \
asm("mov %%rbx, %%rdi\n" \
"cpuid\n" \
"xchg %%rdi, %%rbx\n" \
: "=a" (a), "=D" (b), "=c" (c), "=d" (d) : "a" (inp))
#define cpuid(a, b, c, d, inp) \
asm("mov %%rbx, %%rdi\n" \
"cpuid\n" \
"xchg %%rdi, %%rbx\n" \
: "=a"(a), "=D"(b), "=c"(c), "=d"(d) \
: "a"(inp))
#endif
#if defined(cpuid) // initialize the struct only on x86
#if defined(cpuid) // initialize the struct only on x86
// Set the flags so that code will run correctly and conservatively, so even
// if we haven't been initialized yet, we're probably single threaded, and our
// default values should hopefully be pretty safe.
struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = {
false, // bug can't exist before process spawns multiple threads
false, // bug can't exist before process spawns multiple threads
};
namespace {
@@ -62,9 +64,9 @@ void AtomicOps_Internalx86CPUFeaturesInit() {
// get feature flags in ecx/edx, and family/model in eax
cpuid(eax, ebx, ecx, edx, 1);
int family = (eax >> 8) & 0xf; // family and model fields
int family = (eax >> 8) & 0xf; // family and model fields
int model = (eax >> 4) & 0xf;
if (family == 0xf) { // use extended family and model fields
if (family == 0xf) { // use extended family and model fields
family += (eax >> 20) & 0xff;
model += ((eax >> 16) & 0xf) << 4;
}
@@ -74,9 +76,8 @@ void AtomicOps_Internalx86CPUFeaturesInit() {
// non-locked read-modify-write instruction. Rev F has this bug in
// pre-release versions, but not in versions released to customers,
// so we test only for Rev E, which is family 15, model 32..63 inclusive.
if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD
family == 15 &&
32 <= model && model <= 63) {
if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD
family == 15 && 32 <= model && model <= 63) {
AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true;
} else {
AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false;
@@ -85,9 +86,7 @@ void AtomicOps_Internalx86CPUFeaturesInit() {
class AtomicOpsx86Initializer {
public:
AtomicOpsx86Initializer() {
AtomicOps_Internalx86CPUFeaturesInit();
}
AtomicOpsx86Initializer() { AtomicOps_Internalx86CPUFeaturesInit(); }
};
// A global to get use initialized on startup via static initialization :/

View File

@@ -8,7 +8,6 @@
namespace base {
void DoNothing() {
}
void DoNothing() {}
} // namespace base

View File

@@ -8,12 +8,10 @@
namespace base {
ScopedClosureRunner::ScopedClosureRunner() {
}
ScopedClosureRunner::ScopedClosureRunner() {}
ScopedClosureRunner::ScopedClosureRunner(const Closure& closure)
: closure_(closure) {
}
: closure_(closure) {}
ScopedClosureRunner::~ScopedClosureRunner() {
if (!closure_.is_null())

View File

@@ -31,13 +31,11 @@ bool CallbackBase::Equals(const CallbackBase& other) const {
}
CallbackBase::CallbackBase(BindStateBase* bind_state)
: bind_state_(bind_state),
polymorphic_invoke_(NULL) {
: bind_state_(bind_state), polymorphic_invoke_(NULL) {
DCHECK(!bind_state_.get() || bind_state_->ref_count_ == 1);
}
CallbackBase::~CallbackBase() {
}
CallbackBase::~CallbackBase() {}
} // namespace cef_internal
} // namespace base

View File

@@ -14,8 +14,7 @@
namespace base {
namespace cef_internal {
Lock::Lock() : lock_() {
}
Lock::Lock() : lock_() {}
Lock::~Lock() {
DCHECK(owning_thread_ref_.is_null());

View File

@@ -44,13 +44,13 @@ namespace {
// glibc has two strerror_r functions: a historical GNU-specific one that
// returns type char *, and a POSIX.1-2001 compliant one available since 2.3.4
// that returns int. This wraps the GNU-specific one.
static void POSSIBLY_UNUSED wrap_posix_strerror_r(
char *(*strerror_r_ptr)(int, char *, size_t),
int err,
char *buf,
size_t len) {
static void POSSIBLY_UNUSED
wrap_posix_strerror_r(char* (*strerror_r_ptr)(int, char*, size_t),
int err,
char* buf,
size_t len) {
// GNU version.
char *rc = (*strerror_r_ptr)(err, buf, len);
char* rc = (*strerror_r_ptr)(err, buf, len);
if (rc != buf) {
// glibc did not use buf and returned a static string instead. Copy it
// into buf.
@@ -67,11 +67,12 @@ static void POSSIBLY_UNUSED wrap_posix_strerror_r(
// guarantee that they are handled. This is compiled on all POSIX platforms, but
// it will only be used on Linux if the POSIX strerror_r implementation is
// being used (see below).
static void POSSIBLY_UNUSED wrap_posix_strerror_r(
int (*strerror_r_ptr)(int, char *, size_t),
int err,
char *buf,
size_t len) {
static void POSSIBLY_UNUSED wrap_posix_strerror_r(int (*strerror_r_ptr)(int,
char*,
size_t),
int err,
char* buf,
size_t len) {
int old_errno = errno;
// Have to cast since otherwise we get an error if this is the GNU version
// (but in such a scenario this function is never called). Sadly we can't use
@@ -103,16 +104,13 @@ static void POSSIBLY_UNUSED wrap_posix_strerror_r(
strerror_error = result;
}
// snprintf truncates and always null-terminates.
snprintf(buf,
len,
"Error %d while retrieving error %d",
strerror_error,
snprintf(buf, len, "Error %d while retrieving error %d", strerror_error,
err);
}
errno = old_errno;
}
void safe_strerror_r(int err, char *buf, size_t len) {
void safe_strerror_r(int err, char* buf, size_t len) {
if (buf == NULL || len <= 0) {
return;
}
@@ -136,21 +134,29 @@ std::string safe_strerror(int err) {
// MSVC doesn't like complex extern templates and DLLs.
#if !defined(COMPILER_MSVC)
// Explicit instantiations for commonly used comparisons.
template std::string* MakeCheckOpString<int, int>(
const int&, const int&, const char* names);
template std::string* MakeCheckOpString<int, int>(const int&,
const int&,
const char* names);
template std::string* MakeCheckOpString<unsigned long, unsigned long>(
const unsigned long&, const unsigned long&, const char* names);
const unsigned long&,
const unsigned long&,
const char* names);
template std::string* MakeCheckOpString<unsigned long, unsigned int>(
const unsigned long&, const unsigned int&, const char* names);
const unsigned long&,
const unsigned int&,
const char* names);
template std::string* MakeCheckOpString<unsigned int, unsigned long>(
const unsigned int&, const unsigned long&, const char* names);
const unsigned int&,
const unsigned long&,
const char* names);
template std::string* MakeCheckOpString<std::string, std::string>(
const std::string&, const std::string&, const char* name);
const std::string&,
const std::string&,
const char* name);
#endif
#if defined(OS_WIN)
LogMessage::SaveLastError::SaveLastError() : last_error_(::GetLastError()) {
}
LogMessage::SaveLastError::SaveLastError() : last_error_(::GetLastError()) {}
LogMessage::SaveLastError::~SaveLastError() {
::SetLastError(last_error_);
@@ -158,8 +164,7 @@ LogMessage::SaveLastError::~SaveLastError() {
#endif // defined(OS_WIN)
LogMessage::LogMessage(const char* file, int line, LogSeverity severity)
: severity_(severity), file_(file), line_(line) {
}
: severity_(severity), file_(file), line_(line) {}
LogMessage::LogMessage(const char* file, int line, std::string* result)
: severity_(LOG_FATAL), file_(file), line_(line) {
@@ -167,7 +172,9 @@ LogMessage::LogMessage(const char* file, int line, std::string* result)
delete result;
}
LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
LogMessage::LogMessage(const char* file,
int line,
LogSeverity severity,
std::string* result)
: severity_(severity), file_(file), line_(line) {
stream_ << "Check failed: " << *result;
@@ -211,8 +218,8 @@ std::string SystemErrorCodeToString(SystemErrorCode error_code) {
s.erase(std::remove_if(s.begin(), s.end(), ::isspace), s.end());
ss << s << " (0x" << std::hex << error_code << ")";
} else {
ss << "Error (0x" << std::hex << GetLastError() <<
") while retrieving error. (0x" << error_code << ")";
ss << "Error (0x" << std::hex << GetLastError()
<< ") while retrieving error. (0x" << error_code << ")";
}
return ss.str();
}
@@ -229,9 +236,7 @@ Win32ErrorLogMessage::Win32ErrorLogMessage(const char* file,
int line,
LogSeverity severity,
SystemErrorCode err)
: err_(err),
log_message_(file, line, severity) {
}
: err_(err), log_message_(file, line, severity) {}
Win32ErrorLogMessage::~Win32ErrorLogMessage() {
stream() << ": " << SystemErrorCodeToString(err_);
@@ -241,9 +246,7 @@ ErrnoLogMessage::ErrnoLogMessage(const char* file,
int line,
LogSeverity severity,
SystemErrorCode err)
: err_(err),
log_message_(file, line, severity) {
}
: err_(err), log_message_(file, line, severity) {}
ErrnoLogMessage::~ErrnoLogMessage() {
stream() << ": " << SystemErrorCodeToString(err_);

View File

@@ -35,7 +35,7 @@ int c16memcmp(const char16* s1, const char16* s2, size_t n) {
}
size_t c16len(const char16* s) {
const char16 *s_orig = s;
const char16* s_orig = s;
while (*s) {
++s;
}
@@ -61,7 +61,7 @@ char16* c16memcpy(char16* s1, const char16* s2, size_t n) {
}
char16* c16memset(char16* s, char16 c, size_t n) {
char16 *s_orig = s;
char16* s_orig = s;
while (n-- > 0) {
*s = c;
++s;

View File

@@ -7,8 +7,7 @@
namespace base {
namespace cef_internal {
ThreadCheckerImpl::ThreadCheckerImpl()
: valid_thread_id_() {
ThreadCheckerImpl::ThreadCheckerImpl() : valid_thread_id_() {
EnsureThreadIdAssigned();
}

View File

@@ -31,9 +31,8 @@ void ThreadCollisionWarner::EnterSelf() {
// write on valid_thread_id_ the current thread ID.
subtle::Atomic32 current_thread_id = CurrentThread();
int previous_value = subtle::NoBarrier_CompareAndSwap(&valid_thread_id_,
0,
current_thread_id);
int previous_value =
subtle::NoBarrier_CompareAndSwap(&valid_thread_id_, 0, current_thread_id);
if (previous_value != 0 && previous_value != current_thread_id) {
// gotcha! a thread is trying to use the same class and that is
// not current thread.
@@ -46,8 +45,7 @@ void ThreadCollisionWarner::EnterSelf() {
void ThreadCollisionWarner::Enter() {
subtle::Atomic32 current_thread_id = CurrentThread();
if (subtle::NoBarrier_CompareAndSwap(&valid_thread_id_,
0,
if (subtle::NoBarrier_CompareAndSwap(&valid_thread_id_, 0,
current_thread_id) != 0) {
// gotcha! another thread is trying to use the same class.
asserter_->warn();

View File

@@ -28,22 +28,19 @@ bool WeakReference::Flag::IsValid() const {
return is_valid_;
}
WeakReference::Flag::~Flag() {
WeakReference::Flag::~Flag() {}
WeakReference::WeakReference() {}
WeakReference::WeakReference(const Flag* flag) : flag_(flag) {}
WeakReference::~WeakReference() {}
bool WeakReference::is_valid() const {
return flag_.get() && flag_->IsValid();
}
WeakReference::WeakReference() {
}
WeakReference::WeakReference(const Flag* flag) : flag_(flag) {
}
WeakReference::~WeakReference() {
}
bool WeakReference::is_valid() const { return flag_.get() && flag_->IsValid(); }
WeakReferenceOwner::WeakReferenceOwner() {
}
WeakReferenceOwner::WeakReferenceOwner() {}
WeakReferenceOwner::~WeakReferenceOwner() {
Invalidate();
@@ -64,14 +61,11 @@ void WeakReferenceOwner::Invalidate() {
}
}
WeakPtrBase::WeakPtrBase() {
}
WeakPtrBase::WeakPtrBase() {}
WeakPtrBase::~WeakPtrBase() {
}
WeakPtrBase::~WeakPtrBase() {}
WeakPtrBase::WeakPtrBase(const WeakReference& ref) : ref_(ref) {
}
WeakPtrBase::WeakPtrBase(const WeakReference& ref) : ref_(ref) {}
} // namespace cef_internal
} // namespace base