Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
cpplint: disallow if one-liners
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Oct 16, 2013
1 parent 7063c59 commit 2bc30f2
Show file tree
Hide file tree
Showing 22 changed files with 340 additions and 168 deletions.
12 changes: 8 additions & 4 deletions src/cares_wrap.cc
Expand Up @@ -64,8 +64,10 @@ typedef class ReqWrap<uv_getaddrinfo_t> GetAddrInfoReqWrap;


static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
if (a->sock < b->sock) return -1;
if (a->sock > b->sock) return 1;
if (a->sock < b->sock)
return -1;
if (a->sock > b->sock)
return 1;
return 0;
}

Expand Down Expand Up @@ -810,7 +812,8 @@ static void Query(const FunctionCallbackInfo<Value>& args) {

String::Utf8Value name(string);
int err = wrap->Send(*name);
if (err) delete wrap;
if (err)
delete wrap;

args.GetReturnValue().Set(err);
}
Expand Down Expand Up @@ -974,7 +977,8 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
NULL,
&hints);
req_wrap->Dispatched();
if (err) delete req_wrap;
if (err)
delete req_wrap;

args.GetReturnValue().Set(err);
}
Expand Down
3 changes: 2 additions & 1 deletion src/fs_event_wrap.cc
Expand Up @@ -181,7 +181,8 @@ void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) {
FSEventWrap* wrap;
NODE_UNWRAP_NO_ABORT(args.This(), FSEventWrap, wrap);

if (wrap == NULL || wrap->initialized_ == false) return;
if (wrap == NULL || wrap->initialized_ == false)
return;
wrap->initialized_ = false;

HandleWrap::Close(args);
Expand Down
3 changes: 2 additions & 1 deletion src/handle_wrap.cc
Expand Up @@ -72,7 +72,8 @@ void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
NODE_UNWRAP_NO_ABORT(args.This(), HandleWrap, wrap);

// guard against uninitialized handle or double close
if (wrap == NULL || wrap->handle__ == NULL) return;
if (wrap == NULL || wrap->handle__ == NULL)
return;

Environment* env = wrap->env();
assert(!wrap->persistent().IsEmpty());
Expand Down
57 changes: 38 additions & 19 deletions src/node.cc
Expand Up @@ -164,7 +164,8 @@ ArrayBufferAllocator ArrayBufferAllocator::the_singleton;


void* ArrayBufferAllocator::Allocate(size_t length) {
if (length > kMaxLength) return NULL;
if (length > kMaxLength)
return NULL;
return new char[length];
}

Expand Down Expand Up @@ -839,7 +840,8 @@ Local<Value> WinapiErrnoException(int errorno,
void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());

if (env->using_domains()) return;
if (env->using_domains())
return;
env->set_using_domains(true);

HandleScope scope(node_isolate);
Expand Down Expand Up @@ -1122,7 +1124,8 @@ Handle<Value> MakeDomainCallback(const Handle<Object> object,
enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
HandleScope scope(node_isolate);

if (!encoding_v->IsString()) return _default;
if (!encoding_v->IsString())
return _default;

String::Utf8Value encoding(encoding_v);

Expand Down Expand Up @@ -1203,7 +1206,8 @@ void DisplayExceptionLine(Handle<Message> message) {
// then we want to show the original failure, not the secondary one.
static bool displayed_error = false;

if (displayed_error) return;
if (displayed_error)
return;
displayed_error = true;

uv_tty_reset_mode();
Expand Down Expand Up @@ -1339,7 +1343,8 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {

QUEUE_FOREACH(q, &req_wrap_queue) {
ReqWrap<uv_req_t>* w = container_of(q, ReqWrap<uv_req_t>, req_wrap_queue_);
if (w->persistent().IsEmpty()) continue;
if (w->persistent().IsEmpty())
continue;
ary->Set(i++, w->object());
}

Expand All @@ -1360,10 +1365,12 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {

QUEUE_FOREACH(q, &handle_wrap_queue) {
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
if (w->persistent().IsEmpty() || (w->flags_ & HandleWrap::kUnref)) continue;
if (w->persistent().IsEmpty() || (w->flags_ & HandleWrap::kUnref))
continue;
Local<Object> object = w->object();
Local<Value> owner = object->Get(owner_sym);
if (owner->IsUndefined()) owner = object;
if (owner->IsUndefined())
owner = object;
ary->Set(i++, owner);
}

Expand Down Expand Up @@ -1622,7 +1629,8 @@ static void GetGroups(const FunctionCallbackInfo<Value>& args) {

for (int i = 0; i < ngroups; i++) {
groups_list->Set(i, Integer::New(groups[i], node_isolate));
if (groups[i] == egid) seen_egid = true;
if (groups[i] == egid)
seen_egid = true;
}

delete[] groups;
Expand Down Expand Up @@ -1697,7 +1705,8 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
extra_group = gid_by_name(args[1]);

if (extra_group == gid_not_found) {
if (must_free) free(user);
if (must_free)
free(user);
return ThrowError("initgroups extra group not found");
}

Expand All @@ -1724,7 +1733,8 @@ void Exit(const FunctionCallbackInfo<Value>& args) {
static void Uptime(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
double uptime;
if (uv_uptime(&uptime)) return;
if (uv_uptime(&uptime))
return;
args.GetReturnValue().Set(uptime - prog_start_time);
}

Expand Down Expand Up @@ -1871,7 +1881,8 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
* look for foo_bar_module, not foo-bar_module.
*/
for (pos = symbol; *pos != '\0'; ++pos) {
if (*pos == '-') *pos = '_';
if (*pos == '-')
*pos = '_';
}

node_module_struct *mod;
Expand Down Expand Up @@ -2105,7 +2116,8 @@ static void EnvQuery(Local<String> property,
int32_t rc = -1; // Not found unless proven otherwise.
#ifdef __POSIX__
String::Utf8Value key(property);
if (getenv(*key)) rc = 0;
if (getenv(*key))
rc = 0;
#else // _WIN32
String::Value key(property);
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
Expand All @@ -2120,7 +2132,8 @@ static void EnvQuery(Local<String> property,
}
}
#endif
if (rc != -1) info.GetReturnValue().Set(rc);
if (rc != -1)
info.GetReturnValue().Set(rc);
}


Expand All @@ -2131,7 +2144,8 @@ static void EnvDeleter(Local<String> property,
#ifdef __POSIX__
String::Utf8Value key(property);
rc = getenv(*key) != NULL;
if (rc) unsetenv(*key);
if (rc)
unsetenv(*key);
#else
String::Value key(property);
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
Expand All @@ -2150,7 +2164,8 @@ static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
HandleScope scope(node_isolate);
#ifdef __POSIX__
int size = 0;
while (environ[size]) size++;
while (environ[size])
size++;

Local<Array> env = Array::New(size);

Expand All @@ -2166,7 +2181,8 @@ static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
}
#else // _WIN32
WCHAR* environment = GetEnvironmentStringsW();
if (environment == NULL) return; // This should not happen.
if (environment == NULL)
return; // This should not happen.
Local<Array> env = Array::New();
WCHAR* p = environment;
int i = 0;
Expand Down Expand Up @@ -2394,7 +2410,8 @@ void SetupProcessObject(Environment* env,
if ('0' <= c && c <= '9') {
for (j = i + 1; j < l; j++) {
c = OPENSSL_VERSION_TEXT[j];
if (c == ' ') break;
if (c == ' ')
break;
}
break;
}
Expand Down Expand Up @@ -2671,7 +2688,8 @@ static void ParseDebugOpt(const char* arg) {
return;

fprintf(stderr, "Bad debug option.\n");
if (p) fprintf(stderr, "Debug port must be in range 1025 to 65535.\n");
if (p)
fprintf(stderr, "Debug port must be in range 1025 to 65535.\n");

PrintHelp();
exit(12);
Expand Down Expand Up @@ -2929,7 +2947,8 @@ static int RegisterDebugSignalHandler() {
RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler);
// If we caught a SIGUSR1 during the bootstrap process, re-raise it
// now that the debugger infrastructure is in place.
if (caught_early_debug_signal) raise(SIGUSR1);
if (caught_early_debug_signal)
raise(SIGUSR1);
return 0;
}
#endif // __POSIX__
Expand Down
6 changes: 4 additions & 2 deletions src/node_buffer.cc
Expand Up @@ -471,7 +471,8 @@ void ReadFloatGeneric(const FunctionCallbackInfo<Value>& args) {
const void* data = args.This()->GetIndexedPropertiesExternalArrayData();
const char* ptr = static_cast<const char*>(data) + offset;
memcpy(na.bytes, ptr, sizeof(na.bytes));
if (endianness != GetEndianness()) Swizzle(na.bytes, sizeof(na.bytes));
if (endianness != GetEndianness())
Swizzle(na.bytes, sizeof(na.bytes));

args.GetReturnValue().Set(na.val);
}
Expand Down Expand Up @@ -525,7 +526,8 @@ uint32_t WriteFloatGeneric(const FunctionCallbackInfo<Value>& args) {
union NoAlias na = { val };
void* data = args.This()->GetIndexedPropertiesExternalArrayData();
char* ptr = static_cast<char*>(data) + offset;
if (endianness != GetEndianness()) Swizzle(na.bytes, sizeof(na.bytes));
if (endianness != GetEndianness())
Swizzle(na.bytes, sizeof(na.bytes));
memcpy(ptr, na.bytes, sizeof(na.bytes));
return offset + sizeof(na.bytes);
}
Expand Down

0 comments on commit 2bc30f2

Please sign in to comment.