From 2bc30f239be3e56d642eda38df98c656d55b4d86 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Wed, 16 Oct 2013 20:57:26 +0400 Subject: [PATCH] cpplint: disallow if one-liners --- src/cares_wrap.cc | 12 ++- src/fs_event_wrap.cc | 3 +- src/handle_wrap.cc | 3 +- src/node.cc | 57 ++++++++----- src/node_buffer.cc | 6 +- src/node_crypto.cc | 99 ++++++++++++++------- src/node_crypto.h | 15 ++-- src/node_crypto_bio.cc | 9 +- src/node_file.cc | 180 ++++++++++++++++++++++++++------------- src/node_http_parser.cc | 6 +- src/node_internals.h | 3 +- src/node_object_wrap.h | 6 +- src/node_os.cc | 15 ++-- src/node_stat_watcher.cc | 6 +- src/node_zlib.cc | 3 +- src/stream_wrap.cc | 3 +- src/string_bytes.cc | 57 ++++++++----- src/tcp_wrap.cc | 9 +- src/tls_wrap.cc | 3 +- src/udp_wrap.cc | 6 +- src/uv.cc | 3 +- tools/cpplint.py | 4 + 22 files changed, 340 insertions(+), 168 deletions(-) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 17ada0ee75..d86d8c4758 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -64,8 +64,10 @@ typedef class ReqWrap 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; } @@ -810,7 +812,8 @@ static void Query(const FunctionCallbackInfo& args) { String::Utf8Value name(string); int err = wrap->Send(*name); - if (err) delete wrap; + if (err) + delete wrap; args.GetReturnValue().Set(err); } @@ -974,7 +977,8 @@ static void GetAddrInfo(const FunctionCallbackInfo& args) { NULL, &hints); req_wrap->Dispatched(); - if (err) delete req_wrap; + if (err) + delete req_wrap; args.GetReturnValue().Set(err); } diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 719ee8c7eb..63912f4358 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -181,7 +181,8 @@ void FSEventWrap::Close(const FunctionCallbackInfo& 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); diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index d1c132435d..9fa29623bb 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -72,7 +72,8 @@ void HandleWrap::Close(const FunctionCallbackInfo& 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()); diff --git a/src/node.cc b/src/node.cc index 1a3995c51c..696a942749 100644 --- a/src/node.cc +++ b/src/node.cc @@ -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]; } @@ -839,7 +840,8 @@ Local WinapiErrnoException(int errorno, void SetupDomainUse(const FunctionCallbackInfo& 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); @@ -1122,7 +1124,8 @@ Handle MakeDomainCallback(const Handle object, enum encoding ParseEncoding(Handle 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); @@ -1203,7 +1206,8 @@ void DisplayExceptionLine(Handle 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(); @@ -1339,7 +1343,8 @@ static void GetActiveRequests(const FunctionCallbackInfo& args) { QUEUE_FOREACH(q, &req_wrap_queue) { ReqWrap* w = container_of(q, ReqWrap, req_wrap_queue_); - if (w->persistent().IsEmpty()) continue; + if (w->persistent().IsEmpty()) + continue; ary->Set(i++, w->object()); } @@ -1360,10 +1365,12 @@ void GetActiveHandles(const FunctionCallbackInfo& 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 = w->object(); Local owner = object->Get(owner_sym); - if (owner->IsUndefined()) owner = object; + if (owner->IsUndefined()) + owner = object; ary->Set(i++, owner); } @@ -1622,7 +1629,8 @@ static void GetGroups(const FunctionCallbackInfo& 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; @@ -1697,7 +1705,8 @@ static void InitGroups(const FunctionCallbackInfo& 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"); } @@ -1724,7 +1733,8 @@ void Exit(const FunctionCallbackInfo& args) { static void Uptime(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); double uptime; - if (uv_uptime(&uptime)) return; + if (uv_uptime(&uptime)) + return; args.GetReturnValue().Set(uptime - prog_start_time); } @@ -1871,7 +1881,8 @@ void DLOpen(const FunctionCallbackInfo& 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; @@ -2105,7 +2116,8 @@ static void EnvQuery(Local 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(*key); @@ -2120,7 +2132,8 @@ static void EnvQuery(Local property, } } #endif - if (rc != -1) info.GetReturnValue().Set(rc); + if (rc != -1) + info.GetReturnValue().Set(rc); } @@ -2131,7 +2144,8 @@ static void EnvDeleter(Local 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(*key); @@ -2150,7 +2164,8 @@ static void EnvEnumerator(const PropertyCallbackInfo& info) { HandleScope scope(node_isolate); #ifdef __POSIX__ int size = 0; - while (environ[size]) size++; + while (environ[size]) + size++; Local env = Array::New(size); @@ -2166,7 +2181,8 @@ static void EnvEnumerator(const PropertyCallbackInfo& info) { } #else // _WIN32 WCHAR* environment = GetEnvironmentStringsW(); - if (environment == NULL) return; // This should not happen. + if (environment == NULL) + return; // This should not happen. Local env = Array::New(); WCHAR* p = environment; int i = 0; @@ -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; } @@ -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); @@ -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__ diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 733684d11c..8c5bf3318c 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -471,7 +471,8 @@ void ReadFloatGeneric(const FunctionCallbackInfo& args) { const void* data = args.This()->GetIndexedPropertiesExternalArrayData(); const char* ptr = static_cast(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); } @@ -525,7 +526,8 @@ uint32_t WriteFloatGeneric(const FunctionCallbackInfo& args) { union NoAlias na = { val }; void* data = args.This()->GetIndexedPropertiesExternalArrayData(); char* ptr = static_cast(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); } diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 43a184ba60..17c693bc9f 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -308,7 +308,8 @@ void SecureContext::Init(const FunctionCallbackInfo& args) { // Caller responsible for BIO_free_all-ing the returned object. static BIO* LoadBIO(Handle v) { BIO* bio = NodeBIO::New(); - if (!bio) return NULL; + if (!bio) + return NULL; HandleScope scope(node_isolate); @@ -338,7 +339,8 @@ static X509* LoadX509(Handle v) { HandleScope scope(node_isolate); BIO *bio = LoadBIO(v); - if (!bio) return NULL; + if (!bio) + return NULL; X509 * x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL); if (!x509) { @@ -365,7 +367,8 @@ void SecureContext::SetKey(const FunctionCallbackInfo& args) { } BIO *bio = LoadBIO(args[0]); - if (!bio) return; + if (!bio) + return; String::Utf8Value passphrase(args[1]); @@ -448,7 +451,8 @@ int SSL_CTX_use_certificate_chain(SSL_CTX *ctx, BIO *in) { } end: - if (x != NULL) X509_free(x); + if (x != NULL) + X509_free(x); return ret; } @@ -463,7 +467,8 @@ void SecureContext::SetCert(const FunctionCallbackInfo& args) { } BIO* bio = LoadBIO(args[0]); - if (!bio) return; + if (!bio) + return; int rv = SSL_CTX_use_certificate_chain(sc->ctx_, bio); @@ -495,7 +500,8 @@ void SecureContext::AddCACert(const FunctionCallbackInfo& args) { } X509* x509 = LoadX509(args[0]); - if (!x509) return; + if (!x509) + return; X509_STORE_add_cert(sc->ca_store_, x509); SSL_CTX_add_client_CA(sc->ctx_, x509); @@ -521,7 +527,8 @@ void SecureContext::AddCRL(const FunctionCallbackInfo& args) { (void) &clear_error_on_return; // Silence compiler warning. BIO *bio = LoadBIO(args[0]); - if (!bio) return; + if (!bio) + return; X509_CRL *x509 = PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL); @@ -619,7 +626,8 @@ void SecureContext::SetSessionIdContext( unsigned int sid_ctx_len = sessionIdContext.length(); int r = SSL_CTX_set_session_id_context(sc->ctx_, sid_ctx, sid_ctx_len); - if (r == 1) return; + if (r == 1) + return; BIO* bio; BUF_MEM* mem; @@ -1398,7 +1406,8 @@ void Connection::OnClientHelloParseEnd(void* arg) { int Connection::HandleBIOError(BIO *bio, const char* func, int rv) { - if (rv >= 0) return rv; + if (rv >= 0) + return rv; int retry = BIO_should_retry(bio); (void) retry; // unused if !defined(SSL_PRINT_DEBUG) @@ -1722,7 +1731,8 @@ void Connection::New(const FunctionCallbackInfo& args) { } else { bool reject_unauthorized = args[3]->BooleanValue(); verify_mode = SSL_VERIFY_PEER; - if (reject_unauthorized) verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; + if (reject_unauthorized) + verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; } } else { // Note request_cert and reject_unauthorized are ignored for clients. @@ -2197,7 +2207,8 @@ bool CipherBase::Update(const char* data, int len, unsigned char** out, int* out_len) { - if (!initialised_) return 0; + if (!initialised_) + return 0; *out_len = len + EVP_CIPHER_CTX_block_size(&ctx_); *out = new unsigned char[*out_len]; return EVP_CipherUpdate(&ctx_, @@ -2243,14 +2254,16 @@ void CipherBase::Update(const FunctionCallbackInfo& args) { } Local buf = Buffer::New(env, reinterpret_cast(out), out_len); - if (out) delete[] out; + if (out) + delete[] out; args.GetReturnValue().Set(buf); } bool CipherBase::SetAutoPadding(bool auto_padding) { - if (!initialised_) return false; + if (!initialised_) + return false; return EVP_CIPHER_CTX_set_padding(&ctx_, auto_padding); } @@ -2263,7 +2276,8 @@ void CipherBase::SetAutoPadding(const FunctionCallbackInfo& args) { bool CipherBase::Final(unsigned char** out, int *out_len) { - if (!initialised_) return false; + if (!initialised_) + return false; *out = new unsigned char[EVP_CIPHER_CTX_block_size(&ctx_)]; bool r = EVP_CipherFinal_ex(&ctx_, *out, out_len); @@ -2290,7 +2304,8 @@ void CipherBase::Final(const FunctionCallbackInfo& args) { delete[] out_value; out_value = NULL; out_len = 0; - if (!r) return ThrowCryptoTypeError(ERR_get_error()); + if (!r) + return ThrowCryptoTypeError(ERR_get_error()); } args.GetReturnValue().Set( @@ -2353,7 +2368,8 @@ void Hmac::HmacInit(const FunctionCallbackInfo& args) { bool Hmac::HmacUpdate(const char* data, int len) { - if (!initialised_) return false; + if (!initialised_) + return false; HMAC_Update(&ctx_, reinterpret_cast(data), len); return true; } @@ -2391,7 +2407,8 @@ void Hmac::HmacUpdate(const FunctionCallbackInfo& args) { bool Hmac::HmacDigest(unsigned char** md_value, unsigned int* md_len) { - if (!initialised_) return false; + if (!initialised_) + return false; *md_value = new unsigned char[EVP_MAX_MD_SIZE]; HMAC_Final(&ctx_, *md_value, md_len); HMAC_CTX_cleanup(&ctx_); @@ -2457,7 +2474,8 @@ void Hash::New(const FunctionCallbackInfo& args) { bool Hash::HashInit(const char* hash_type) { assert(md_ == NULL); md_ = EVP_get_digestbyname(hash_type); - if (md_ == NULL) return false; + if (md_ == NULL) + return false; EVP_MD_CTX_init(&mdctx_); EVP_DigestInit_ex(&mdctx_, md_, NULL); initialised_ = true; @@ -2466,7 +2484,8 @@ bool Hash::HashInit(const char* hash_type) { bool Hash::HashUpdate(const char* data, int len) { - if (!initialised_) return false; + if (!initialised_) + return false; EVP_DigestUpdate(&mdctx_, data, len); return true; } @@ -2577,7 +2596,8 @@ void Sign::SignInit(const FunctionCallbackInfo& args) { bool Sign::SignUpdate(const char* data, int len) { - if (!initialised_) return false; + if (!initialised_) + return false; EVP_SignUpdate(&mdctx_, data, len); return true; } @@ -2618,15 +2638,18 @@ bool Sign::SignFinal(unsigned char** md_value, unsigned int *md_len, const char* key_pem, int key_pem_len) { - if (!initialised_) return false; + if (!initialised_) + return false; BIO* bp = NULL; EVP_PKEY* pkey = NULL; bp = BIO_new(BIO_s_mem()); - if (!BIO_write(bp, key_pem, key_pem_len)) return false; + if (!BIO_write(bp, key_pem, key_pem_len)) + return false; pkey = PEM_read_bio_PrivateKey(bp, NULL, NULL, NULL); - if (pkey == NULL) return 0; + if (pkey == NULL) + return 0; EVP_SignFinal(&mdctx_, *md_value, md_len, pkey); EVP_MD_CTX_cleanup(&mdctx_); @@ -2719,7 +2742,8 @@ void Verify::VerifyInit(const FunctionCallbackInfo& args) { bool Verify::VerifyUpdate(const char* data, int len) { - if (!initialised_) return false; + if (!initialised_) + return false; EVP_VerifyUpdate(&mdctx_, data, len); return true; } @@ -2791,7 +2815,8 @@ bool Verify::VerifyFinal(const char* key_pem, RSA* rsa = PEM_read_bio_RSAPublicKey(bp, NULL, NULL, NULL); if (rsa) { pkey = EVP_PKEY_new(); - if (pkey) EVP_PKEY_set1_RSA(pkey, rsa); + if (pkey) + EVP_PKEY_set1_RSA(pkey, rsa); RSA_free(rsa); } if (pkey == NULL) @@ -2906,7 +2931,8 @@ bool DiffieHellman::Init(int primeLength) { dh = DH_new(); DH_generate_parameters_ex(dh, primeLength, DH_GENERATOR_2, 0); bool result = VerifyContext(); - if (!result) return false; + if (!result) + return false; initialised_ = true; return true; } @@ -2916,9 +2942,11 @@ bool DiffieHellman::Init(const char* p, int p_len) { dh = DH_new(); dh->p = BN_bin2bn(reinterpret_cast(p), p_len, 0); dh->g = BN_new(); - if (!BN_set_word(dh->g, 2)) return false; + if (!BN_set_word(dh->g, 2)) + return false; bool result = VerifyContext(); - if (!result) return false; + if (!result) + return false; initialised_ = true; return true; } @@ -3211,11 +3239,16 @@ void DiffieHellman::SetPrivateKey(const FunctionCallbackInfo& args) { bool DiffieHellman::VerifyContext() { int codes; - if (!DH_check(dh, &codes)) return false; - if (codes & DH_CHECK_P_NOT_SAFE_PRIME) return false; - if (codes & DH_CHECK_P_NOT_PRIME) return false; - if (codes & DH_UNABLE_TO_CHECK_GENERATOR) return false; - if (codes & DH_NOT_SUITABLE_GENERATOR) return false; + if (!DH_check(dh, &codes)) + return false; + if (codes & DH_CHECK_P_NOT_SAFE_PRIME) + return false; + if (codes & DH_CHECK_P_NOT_PRIME) + return false; + if (codes & DH_UNABLE_TO_CHECK_GENERATOR) + return false; + if (codes & DH_NOT_SUITABLE_GENERATOR) + return false; return true; } diff --git a/src/node_crypto.h b/src/node_crypto.h index 01a4db820f..094105eed2 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -354,7 +354,8 @@ class CipherBase : public WeakObject { } ~CipherBase() { - if (!initialised_) return; + if (!initialised_) + return; EVP_CIPHER_CTX_cleanup(&ctx_); } @@ -386,7 +387,8 @@ class Hmac : public WeakObject { } ~Hmac() { - if (!initialised_) return; + if (!initialised_) + return; HMAC_CTX_cleanup(&ctx_); } @@ -415,7 +417,8 @@ class Hash : public WeakObject { } ~Hash() { - if (!initialised_) return; + if (!initialised_) + return; EVP_MD_CTX_cleanup(&mdctx_); } @@ -449,7 +452,8 @@ class Sign : public WeakObject { } ~Sign() { - if (!initialised_) return; + if (!initialised_) + return; EVP_MD_CTX_cleanup(&mdctx_); } @@ -483,7 +487,8 @@ class Verify : public WeakObject { } ~Verify() { - if (!initialised_) return; + if (!initialised_) + return; EVP_MD_CTX_cleanup(&mdctx_); } diff --git a/src/node_crypto_bio.cc b/src/node_crypto_bio.cc index 1516fbdf37..f5c012d263 100644 --- a/src/node_crypto_bio.cc +++ b/src/node_crypto_bio.cc @@ -59,7 +59,8 @@ int NodeBIO::New(BIO* bio) { int NodeBIO::Free(BIO* bio) { - if (bio == NULL) return 0; + if (bio == NULL) + return 0; if (bio->shutdown) { if (bio->init && bio->ptr != NULL) { @@ -118,10 +119,12 @@ int NodeBIO::Gets(BIO* bio, char* out, int size) { int i = nbio->IndexOf('\n', size); // Include '\n' - if (i < size) i++; + if (i < size) + i++; // Shift `i` a bit to NULL-terminate string later - if (size == i) i--; + if (size == i) + i--; // Flush read data nbio->Read(out, i); diff --git a/src/node_file.cc b/src/node_file.cc index a6905aa3e1..3bf29c8109 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -73,7 +73,8 @@ class FSReqWrap: public ReqWrap { } void ReleaseEarly() { - if (data_ == NULL) return; + if (data_ == NULL) + return; delete[] data_; data_ = NULL; } @@ -255,7 +256,8 @@ struct fs_req_wrap { &req_wrap.req, \ __VA_ARGS__, \ NULL); \ - if (err < 0) return ThrowUVException(err, #func, NULL, path); \ + if (err < 0) \ + return ThrowUVException(err, #func, NULL, path); \ #define SYNC_REQ req_wrap.req @@ -304,7 +306,8 @@ Local BuildStatsObject(Environment* env, const uv_stat_t* s) { #define X(name) \ { \ Local val = Integer::New(s->st_##name, node_isolate); \ - if (val.IsEmpty()) return Local(); \ + if (val.IsEmpty()) \ + return Local(); \ stats->Set(env->name ## _string(), val); \ } X(dev) @@ -321,7 +324,8 @@ Local BuildStatsObject(Environment* env, const uv_stat_t* s) { #define X(name) \ { \ Local val = Number::New(static_cast(s->st_##name)); \ - if (val.IsEmpty()) return Local(); \ + if (val.IsEmpty()) \ + return Local(); \ stats->Set(env->name ## _string(), val); \ } X(ino) @@ -336,7 +340,8 @@ Local BuildStatsObject(Environment* env, const uv_stat_t* s) { double msecs = static_cast(s->st_##rec.tv_sec) * 1000; \ msecs += static_cast(s->st_##rec.tv_nsec / 1000000); \ Local val = v8::Date::New(msecs); \ - if (val.IsEmpty()) return Local(); \ + if (val.IsEmpty()) \ + return Local(); \ stats->Set(env->name ## _string(), val); \ } X(atime, atim) @@ -351,8 +356,10 @@ Local BuildStatsObject(Environment* env, const uv_stat_t* s) { static void Stat(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - if (args.Length() < 1) return TYPE_ERROR("path required"); - if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); + if (args.Length() < 1) + return TYPE_ERROR("path required"); + if (!args[0]->IsString()) + return TYPE_ERROR("path must be a string"); String::Utf8Value path(args[0]); @@ -368,8 +375,10 @@ static void Stat(const FunctionCallbackInfo& args) { static void LStat(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - if (args.Length() < 1) return TYPE_ERROR("path required"); - if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); + if (args.Length() < 1) + return TYPE_ERROR("path required"); + if (!args[0]->IsString()) + return TYPE_ERROR("path must be a string"); String::Utf8Value path(args[0]); @@ -404,10 +413,14 @@ static void Symlink(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); int len = args.Length(); - if (len < 1) return TYPE_ERROR("dest path required"); - if (len < 2) return TYPE_ERROR("src path required"); - if (!args[0]->IsString()) return TYPE_ERROR("dest path must be a string"); - if (!args[1]->IsString()) return TYPE_ERROR("src path must be a string"); + if (len < 1) + return TYPE_ERROR("dest path required"); + if (len < 2) + return TYPE_ERROR("src path required"); + if (!args[0]->IsString()) + return TYPE_ERROR("dest path must be a string"); + if (!args[1]->IsString()) + return TYPE_ERROR("src path must be a string"); String::Utf8Value dest(args[0]); String::Utf8Value path(args[1]); @@ -435,10 +448,14 @@ static void Link(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); int len = args.Length(); - if (len < 1) return TYPE_ERROR("dest path required"); - if (len < 2) return TYPE_ERROR("src path required"); - if (!args[0]->IsString()) return TYPE_ERROR("dest path must be a string"); - if (!args[1]->IsString()) return TYPE_ERROR("src path must be a string"); + if (len < 1) + return TYPE_ERROR("dest path required"); + if (len < 2) + return TYPE_ERROR("src path required"); + if (!args[0]->IsString()) + return TYPE_ERROR("dest path must be a string"); + if (!args[1]->IsString()) + return TYPE_ERROR("src path must be a string"); String::Utf8Value orig_path(args[0]); String::Utf8Value new_path(args[1]); @@ -453,8 +470,10 @@ static void Link(const FunctionCallbackInfo& args) { static void ReadLink(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - if (args.Length() < 1) return TYPE_ERROR("path required"); - if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); + if (args.Length() < 1) + return TYPE_ERROR("path required"); + if (!args[0]->IsString()) + return TYPE_ERROR("path must be a string"); String::Utf8Value path(args[0]); @@ -472,10 +491,14 @@ static void Rename(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); int len = args.Length(); - if (len < 1) return TYPE_ERROR("old path required"); - if (len < 2) return TYPE_ERROR("new path required"); - if (!args[0]->IsString()) return TYPE_ERROR("old path must be a string"); - if (!args[1]->IsString()) return TYPE_ERROR("new path must be a string"); + if (len < 1) + return TYPE_ERROR("old path required"); + if (len < 2) + return TYPE_ERROR("new path required"); + if (!args[0]->IsString()) + return TYPE_ERROR("old path must be a string"); + if (!args[1]->IsString()) + return TYPE_ERROR("new path must be a string"); String::Utf8Value old_path(args[0]); String::Utf8Value new_path(args[1]); @@ -541,8 +564,10 @@ static void Fsync(const FunctionCallbackInfo& args) { static void Unlink(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - if (args.Length() < 1) return TYPE_ERROR("path required"); - if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); + if (args.Length() < 1) + return TYPE_ERROR("path required"); + if (!args[0]->IsString()) + return TYPE_ERROR("path must be a string"); String::Utf8Value path(args[0]); @@ -556,8 +581,10 @@ static void Unlink(const FunctionCallbackInfo& args) { static void RMDir(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - if (args.Length() < 1) return TYPE_ERROR("path required"); - if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); + if (args.Length() < 1) + return TYPE_ERROR("path required"); + if (!args[0]->IsString()) + return TYPE_ERROR("path must be a string"); String::Utf8Value path(args[0]); @@ -588,8 +615,10 @@ static void MKDir(const FunctionCallbackInfo& args) { static void ReadDir(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - if (args.Length() < 1) return TYPE_ERROR("path required"); - if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); + if (args.Length() < 1) + return TYPE_ERROR("path required"); + if (!args[0]->IsString()) + return TYPE_ERROR("path must be a string"); String::Utf8Value path(args[0]); @@ -622,12 +651,18 @@ static void Open(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); int len = args.Length(); - if (len < 1) return TYPE_ERROR("path required"); - if (len < 2) return TYPE_ERROR("flags required"); - if (len < 3) return TYPE_ERROR("mode required"); - if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - if (!args[1]->IsInt32()) return TYPE_ERROR("flags must be an int"); - if (!args[2]->IsInt32()) return TYPE_ERROR("mode must be an int"); + if (len < 1) + return TYPE_ERROR("path required"); + if (len < 2) + return TYPE_ERROR("flags required"); + if (len < 3) + return TYPE_ERROR("mode required"); + if (!args[0]->IsString()) + return TYPE_ERROR("path must be a string"); + if (!args[1]->IsInt32()) + return TYPE_ERROR("flags must be an int"); + if (!args[2]->IsInt32()) + return TYPE_ERROR("mode must be an int"); String::Utf8Value path(args[0]); int flags = args[1]->Int32Value(); @@ -727,7 +762,8 @@ static void WriteString(const FunctionCallbackInfo& args) { if (!cb->IsFunction()) { SYNC_CALL(write, NULL, fd, buf, len, pos) - if (must_free) delete[] buf; + if (must_free) + delete[] buf; return args.GetReturnValue().Set(SYNC_RESULT); } @@ -860,12 +896,18 @@ static void Chown(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); int len = args.Length(); - if (len < 1) return TYPE_ERROR("path required"); - if (len < 2) return TYPE_ERROR("uid required"); - if (len < 3) return TYPE_ERROR("gid required"); - if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - if (!args[1]->IsUint32()) return TYPE_ERROR("uid must be an unsigned int"); - if (!args[2]->IsUint32()) return TYPE_ERROR("gid must be an unsigned int"); + if (len < 1) + return TYPE_ERROR("path required"); + if (len < 2) + return TYPE_ERROR("uid required"); + if (len < 3) + return TYPE_ERROR("gid required"); + if (!args[0]->IsString()) + return TYPE_ERROR("path must be a string"); + if (!args[1]->IsUint32()) + return TYPE_ERROR("uid must be an unsigned int"); + if (!args[2]->IsUint32()) + return TYPE_ERROR("gid must be an unsigned int"); String::Utf8Value path(args[0]); uv_uid_t uid = static_cast(args[1]->Uint32Value()); @@ -886,12 +928,18 @@ static void FChown(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); int len = args.Length(); - if (len < 1) return TYPE_ERROR("fd required"); - if (len < 2) return TYPE_ERROR("uid required"); - if (len < 3) return TYPE_ERROR("gid required"); - if (!args[0]->IsInt32()) return TYPE_ERROR("fd must be an int"); - if (!args[1]->IsUint32()) return TYPE_ERROR("uid must be an unsigned int"); - if (!args[2]->IsUint32()) return TYPE_ERROR("gid must be an unsigned int"); + if (len < 1) + return TYPE_ERROR("fd required"); + if (len < 2) + return TYPE_ERROR("uid required"); + if (len < 3) + return TYPE_ERROR("gid required"); + if (!args[0]->IsInt32()) + return TYPE_ERROR("fd must be an int"); + if (!args[1]->IsUint32()) + return TYPE_ERROR("uid must be an unsigned int"); + if (!args[2]->IsUint32()) + return TYPE_ERROR("gid must be an unsigned int"); int fd = args[0]->Int32Value(); uv_uid_t uid = static_cast(args[1]->Uint32Value()); @@ -909,12 +957,18 @@ static void UTimes(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); int len = args.Length(); - if (len < 1) return TYPE_ERROR("path required"); - if (len < 2) return TYPE_ERROR("atime required"); - if (len < 3) return TYPE_ERROR("mtime required"); - if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - if (!args[1]->IsNumber()) return TYPE_ERROR("atime must be a number"); - if (!args[2]->IsNumber()) return TYPE_ERROR("mtime must be a number"); + if (len < 1) + return TYPE_ERROR("path required"); + if (len < 2) + return TYPE_ERROR("atime required"); + if (len < 3) + return TYPE_ERROR("mtime required"); + if (!args[0]->IsString()) + return TYPE_ERROR("path must be a string"); + if (!args[1]->IsNumber()) + return TYPE_ERROR("atime must be a number"); + if (!args[2]->IsNumber()) + return TYPE_ERROR("mtime must be a number"); const String::Utf8Value path(args[0]); const double atime = static_cast(args[1]->NumberValue()); @@ -931,12 +985,18 @@ static void FUTimes(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); int len = args.Length(); - if (len < 1) return TYPE_ERROR("fd required"); - if (len < 2) return TYPE_ERROR("atime required"); - if (len < 3) return TYPE_ERROR("mtime required"); - if (!args[0]->IsInt32()) return TYPE_ERROR("fd must be an int"); - if (!args[1]->IsNumber()) return TYPE_ERROR("atime must be a number"); - if (!args[2]->IsNumber()) return TYPE_ERROR("mtime must be a number"); + if (len < 1) + return TYPE_ERROR("fd required"); + if (len < 2) + return TYPE_ERROR("atime required"); + if (len < 3) + return TYPE_ERROR("mtime required"); + if (!args[0]->IsInt32()) + return TYPE_ERROR("fd must be an int"); + if (!args[1]->IsNumber()) + return TYPE_ERROR("atime must be a number"); + if (!args[2]->IsNumber()) + return TYPE_ERROR("mtime must be a number"); const int fd = args[0]->Int32Value(); const double atime = static_cast(args[1]->NumberValue()); diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index f7faf0d792..c63ea73a43 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -417,7 +417,8 @@ class Parser : public WeakObject { parser->current_buffer_data_ = NULL; // If there was an exception in one of the callbacks - if (parser->got_exception_) return; + if (parser->got_exception_) + return; Local nparsed_obj = Integer::New(nparsed, node_isolate); // If there was a parse error in one of the callbacks @@ -449,7 +450,8 @@ class Parser : public WeakObject { int rv = http_parser_execute(&(parser->parser_), &settings, NULL, 0); - if (parser->got_exception_) return; + if (parser->got_exception_) + return; if (rv != 0) { enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_); diff --git a/src/node_internals.h b/src/node_internals.h index 141bd92ff0..fa3b5d763d 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -91,7 +91,8 @@ inline static int snprintf(char* buf, unsigned int len, const char* fmt, ...) { va_list ap; va_start(ap, fmt); int n = _vsprintf_p(buf, len, fmt, ap); - if (len) buf[len - 1] = '\0'; + if (len) + buf[len - 1] = '\0'; va_end(ap); return n; } diff --git a/src/node_object_wrap.h b/src/node_object_wrap.h index 683123559f..538af3520d 100644 --- a/src/node_object_wrap.h +++ b/src/node_object_wrap.h @@ -45,7 +45,8 @@ class NODE_EXTERN ObjectWrap { virtual ~ObjectWrap() { - if (persistent().IsEmpty()) return; + if (persistent().IsEmpty()) + return; assert(persistent().IsNearDeath()); persistent().ClearWeak(); persistent().Dispose(); @@ -117,7 +118,8 @@ class NODE_EXTERN ObjectWrap { assert(!persistent().IsEmpty()); assert(!persistent().IsWeak()); assert(refs_ > 0); - if (--refs_ == 0) MakeWeak(); + if (--refs_ == 0) + MakeWeak(); } int refs_; // ro diff --git a/src/node_os.cc b/src/node_os.cc index e3d9971e3e..bed5a09b20 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -115,7 +115,8 @@ static void GetOSRelease(const FunctionCallbackInfo& args) { OSVERSIONINFO info; info.dwOSVersionInfoSize = sizeof(info); - if (GetVersionEx(&info) == 0) return; + if (GetVersionEx(&info) == 0) + return; snprintf(release, sizeof(release), @@ -136,7 +137,8 @@ static void GetCPUInfo(const FunctionCallbackInfo& args) { int count, i; int err = uv_cpu_info(&cpu_infos, &count); - if (err) return; + if (err) + return; Local cpus = Array::New(); for (i = 0; i < count; i++) { @@ -172,7 +174,8 @@ static void GetCPUInfo(const FunctionCallbackInfo& args) { static void GetFreeMemory(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); double amount = uv_get_free_memory(); - if (amount < 0) return; + if (amount < 0) + return; args.GetReturnValue().Set(amount); } @@ -180,7 +183,8 @@ static void GetFreeMemory(const FunctionCallbackInfo& args) { static void GetTotalMemory(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); double amount = uv_get_total_memory(); - if (amount < 0) return; + if (amount < 0) + return; args.GetReturnValue().Set(amount); } @@ -189,7 +193,8 @@ static void GetUptime(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); double uptime; int err = uv_uptime(&uptime); - if (err == 0) args.GetReturnValue().Set(uptime); + if (err == 0) + args.GetReturnValue().Set(uptime); } diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index 45936fe93c..3468cc38ad 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -117,7 +117,8 @@ void StatWatcher::Start(const FunctionCallbackInfo& args) { const bool persistent = args[1]->BooleanValue(); const uint32_t interval = args[2]->Uint32Value(); - if (!persistent) uv_unref(reinterpret_cast(wrap->watcher_)); + if (!persistent) + uv_unref(reinterpret_cast(wrap->watcher_)); uv_fs_poll_start(wrap->watcher_, Callback, *path, interval); wrap->ClearWeak(); } @@ -134,7 +135,8 @@ void StatWatcher::Stop(const FunctionCallbackInfo& args) { void StatWatcher::Stop() { - if (!uv_is_active(reinterpret_cast(watcher_))) return; + if (!uv_is_active(reinterpret_cast(watcher_))) + return; uv_fs_poll_stop(watcher_); MakeWeak(); } diff --git a/src/node_zlib.cc b/src/node_zlib.cc index e9de782d0e..ac3a296c0b 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -459,7 +459,8 @@ class ZCtx : public WeakObject { } static void SetDictionary(ZCtx* ctx) { - if (ctx->dictionary_ == NULL) return; + if (ctx->dictionary_ == NULL) + return; ctx->err_ = Z_OK; diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index f1949d9829..f268bde3b6 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -481,7 +481,8 @@ void StreamWrap::Shutdown(const FunctionCallbackInfo& args) { ShutdownWrap* req_wrap = new ShutdownWrap(env, req_wrap_obj); int err = wrap->callbacks()->DoShutdown(req_wrap, AfterShutdown); req_wrap->Dispatched(); - if (err) delete req_wrap; + if (err) + delete req_wrap; args.GetReturnValue().Set(err); } diff --git a/src/string_bytes.cc b/src/string_bytes.cc index 6e25b3c60e..5fc34416fb 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -173,26 +173,36 @@ size_t base64_decode(char* buf, while (src < srcEnd && dst < dstEnd) { int remaining = srcEnd - src; - while (unbase64(*src) < 0 && src < srcEnd) src++, remaining--; - if (remaining == 0 || *src == '=') break; + while (unbase64(*src) < 0 && src < srcEnd) + src++, remaining--; + if (remaining == 0 || *src == '=') + break; a = unbase64(*src++); - while (unbase64(*src) < 0 && src < srcEnd) src++, remaining--; - if (remaining <= 1 || *src == '=') break; + while (unbase64(*src) < 0 && src < srcEnd) + src++, remaining--; + if (remaining <= 1 || *src == '=') + break; b = unbase64(*src++); *dst++ = (a << 2) | ((b & 0x30) >> 4); - if (dst == dstEnd) break; + if (dst == dstEnd) + break; - while (unbase64(*src) < 0 && src < srcEnd) src++, remaining--; - if (remaining <= 2 || *src == '=') break; + while (unbase64(*src) < 0 && src < srcEnd) + src++, remaining--; + if (remaining <= 2 || *src == '=') + break; c = unbase64(*src++); *dst++ = ((b & 0x0F) << 4) | ((c & 0x3C) >> 2); - if (dst == dstEnd) break; + if (dst == dstEnd) + break; - while (unbase64(*src) < 0 && src < srcEnd) src++, remaining--; - if (remaining <= 3 || *src == '=') break; + while (unbase64(*src) < 0 && src < srcEnd) + src++, remaining--; + if (remaining <= 3 || *src == '=') + break; d = unbase64(*src++); *dst++ = ((c & 0x03) << 6) | (d & 0x3F); @@ -206,9 +216,12 @@ size_t base64_decode(char* buf, template unsigned hex2bin(TypeName c) { - if (c >= '0' && c <= '9') return c - '0'; - if (c >= 'A' && c <= 'F') return 10 + (c - 'A'); - if (c >= 'a' && c <= 'f') return 10 + (c - 'a'); + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'A' && c <= 'F') + return 10 + (c - 'A'); + if (c >= 'a' && c <= 'f') + return 10 + (c - 'a'); return static_cast(-1); } @@ -222,7 +235,8 @@ size_t hex_decode(char* buf, for (i = 0; i < len && i * 2 + 1 < srcLen; ++i) { unsigned a = hex2bin(src[i * 2 + 0]); unsigned b = hex2bin(src[i * 2 + 1]); - if (!~a || !~b) return i; + if (!~a || !~b) + return i; buf[i] = a * 16 + b; } @@ -345,7 +359,8 @@ size_t StringBytes::Write(char* buf, bool StringBytes::IsValidString(Handle string, enum encoding enc) { - if (enc == HEX && string->Length() % 2 != 0) return false; + if (enc == HEX && string->Length() % 2 != 0) + return false; // TODO(bnoordhuis) Add BASE64 check? return true; } @@ -453,7 +468,8 @@ size_t StringBytes::Size(Handle val, enum encoding encoding) { static bool contains_non_ascii_slow(const char* buf, size_t len) { for (size_t i = 0; i < len; ++i) { - if (buf[i] & 0x80) return true; + if (buf[i] & 0x80) + return true; } return false; } @@ -470,7 +486,8 @@ static bool contains_non_ascii(const char* src, size_t len) { if (unaligned > 0) { const unsigned n = bytes_per_word - unaligned; - if (contains_non_ascii_slow(src, n)) return true; + if (contains_non_ascii_slow(src, n)) + return true; src += n; len -= n; } @@ -485,13 +502,15 @@ static bool contains_non_ascii(const char* src, size_t len) { const uintptr_t* srcw = reinterpret_cast(src); for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) { - if (srcw[i] & mask) return true; + if (srcw[i] & mask) + return true; } const unsigned remainder = len & align_mask; if (remainder > 0) { const size_t offset = len - remainder; - if (contains_non_ascii_slow(src + offset, remainder)) return true; + if (contains_non_ascii_slow(src + offset, remainder)) + return true; } return false; diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 305ee1db2b..e0cab70e7f 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -400,7 +400,8 @@ void TCPWrap::Connect(const FunctionCallbackInfo& args) { reinterpret_cast(&addr), AfterConnect); req_wrap->Dispatched(); - if (err) delete req_wrap; + if (err) + delete req_wrap; } args.GetReturnValue().Set(err); @@ -432,7 +433,8 @@ void TCPWrap::Connect6(const FunctionCallbackInfo& args) { reinterpret_cast(&addr), AfterConnect); req_wrap->Dispatched(); - if (err) delete req_wrap; + if (err) + delete req_wrap; } args.GetReturnValue().Set(err); @@ -449,7 +451,8 @@ Local AddressToJS(Environment* env, const sockaddr_in6 *a6; int port; - if (info.IsEmpty()) info = Object::New(); + if (info.IsEmpty()) + info = Object::New(); switch (addr->sa_family) { case AF_INET6: diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index a0eea75c63..6986e5a3c1 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -597,7 +597,8 @@ void TLSCallbacks::SetVerifyMode(const FunctionCallbackInfo& args) { } else { bool reject_unauthorized = args[1]->IsTrue(); verify_mode = SSL_VERIFY_PEER; - if (reject_unauthorized) verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; + if (reject_unauthorized) + verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; } } else { // Note request_cert and reject_unauthorized are ignored for clients. diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 151789d259..10935768bf 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -297,7 +297,8 @@ void UDPWrap::DoSend(const FunctionCallbackInfo& args, int family) { } req_wrap->Dispatched(); - if (err) delete req_wrap; + if (err) + delete req_wrap; args.GetReturnValue().Set(err); } @@ -320,7 +321,8 @@ void UDPWrap::RecvStart(const FunctionCallbackInfo& args) { int err = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv); // UV_EALREADY means that the socket is already bound but that's okay - if (err == UV_EALREADY) err = 0; + if (err == UV_EALREADY) + err = 0; args.GetReturnValue().Set(err); } diff --git a/src/uv.cc b/src/uv.cc index 2759d29671..988fc70299 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -39,7 +39,8 @@ using v8::Value; void ErrName(const FunctionCallbackInfo& args) { v8::HandleScope handle_scope(node_isolate); int err = args[0]->Int32Value(); - if (err >= 0) return ThrowError("err >= 0"); + if (err >= 0) + return ThrowError("err >= 0"); const char* name = uv_err_name(err); args.GetReturnValue().Set(OneByteString(node_isolate, name)); } diff --git a/tools/cpplint.py b/tools/cpplint.py index 5dd1b25a25..603c4aba97 100644 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -1764,6 +1764,10 @@ def CheckSpacing(filename, clean_lines, linenum, error): error(filename, linenum, 'whitespace/operators', 4, 'Missing spaces around =') + if Match(r'^\s*(if|while) .*[^\{,)&|\\]$', line): + error(filename, linenum, 'whitespace/if-one-line', 4, + 'If\'s body on the same line as if itself') + # It's ok not to have spaces around binary operators like + - * /, but if # there's too little whitespace, we get concerned. It's hard to tell, # though, so we punt on this one for now. TODO.