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;
}
String::Utf8Value name(string);
int err = wrap->Send(*name);
- if (err) delete wrap;
+ if (err)
+ delete wrap;
args.GetReturnValue().Set(err);
}
NULL,
&hints);
req_wrap->Dispatched();
- if (err) delete req_wrap;
+ if (err)
+ delete req_wrap;
args.GetReturnValue().Set(err);
}
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);
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());
void* ArrayBufferAllocator::Allocate(size_t length) {
- if (length > kMaxLength) return NULL;
+ if (length > kMaxLength)
+ return NULL;
return new char[length];
}
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);
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);
// 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();
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());
}
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);
}
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;
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");
}
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);
}
* 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;
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);
}
}
#endif
- if (rc != -1) info.GetReturnValue().Set(rc);
+ if (rc != -1)
+ info.GetReturnValue().Set(rc);
}
#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);
HandleScope scope(node_isolate);
#ifdef __POSIX__
int size = 0;
- while (environ[size]) size++;
+ while (environ[size])
+ size++;
Local<Array> env = Array::New(size);
}
#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;
if ('0' <= c && c <= '9') {
for (j = i + 1; j < l; j++) {
c = OPENSSL_VERSION_TEXT[j];
- if (c == ' ') break;
+ if (c == ' ')
+ break;
}
break;
}
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);
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__
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);
}
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);
}
// Caller responsible for BIO_free_all-ing the returned object.
static BIO* LoadBIO(Handle<Value> v) {
BIO* bio = NodeBIO::New();
- if (!bio) return NULL;
+ if (!bio)
+ return NULL;
HandleScope scope(node_isolate);
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) {
}
BIO *bio = LoadBIO(args[0]);
- if (!bio) return;
+ if (!bio)
+ return;
String::Utf8Value passphrase(args[1]);
}
end:
- if (x != NULL) X509_free(x);
+ if (x != NULL)
+ X509_free(x);
return ret;
}
}
BIO* bio = LoadBIO(args[0]);
- if (!bio) return;
+ if (!bio)
+ return;
int rv = SSL_CTX_use_certificate_chain(sc->ctx_, bio);
}
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);
(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);
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;
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)
} 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.
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_,
}
Local<Object> buf = Buffer::New(env, reinterpret_cast<char*>(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);
}
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);
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(
bool Hmac::HmacUpdate(const char* data, int len) {
- if (!initialised_) return false;
+ if (!initialised_)
+ return false;
HMAC_Update(&ctx_, reinterpret_cast<const unsigned char*>(data), len);
return true;
}
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_);
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;
bool Hash::HashUpdate(const char* data, int len) {
- if (!initialised_) return false;
+ if (!initialised_)
+ return false;
EVP_DigestUpdate(&mdctx_, data, len);
return true;
}
bool Sign::SignUpdate(const char* data, int len) {
- if (!initialised_) return false;
+ if (!initialised_)
+ return false;
EVP_SignUpdate(&mdctx_, data, len);
return true;
}
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_);
bool Verify::VerifyUpdate(const char* data, int len) {
- if (!initialised_) return false;
+ if (!initialised_)
+ return false;
EVP_VerifyUpdate(&mdctx_, data, len);
return true;
}
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)
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;
}
dh = DH_new();
dh->p = BN_bin2bn(reinterpret_cast<const unsigned char*>(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;
}
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;
}
}
~CipherBase() {
- if (!initialised_) return;
+ if (!initialised_)
+ return;
EVP_CIPHER_CTX_cleanup(&ctx_);
}
}
~Hmac() {
- if (!initialised_) return;
+ if (!initialised_)
+ return;
HMAC_CTX_cleanup(&ctx_);
}
}
~Hash() {
- if (!initialised_) return;
+ if (!initialised_)
+ return;
EVP_MD_CTX_cleanup(&mdctx_);
}
}
~Sign() {
- if (!initialised_) return;
+ if (!initialised_)
+ return;
EVP_MD_CTX_cleanup(&mdctx_);
}
}
~Verify() {
- if (!initialised_) return;
+ if (!initialised_)
+ return;
EVP_MD_CTX_cleanup(&mdctx_);
}
int NodeBIO::Free(BIO* bio) {
- if (bio == NULL) return 0;
+ if (bio == NULL)
+ return 0;
if (bio->shutdown) {
if (bio->init && bio->ptr != NULL) {
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);
}
void ReleaseEarly() {
- if (data_ == NULL) return;
+ if (data_ == NULL)
+ return;
delete[] data_;
data_ = NULL;
}
&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
#define X(name) \
{ \
Local<Value> val = Integer::New(s->st_##name, node_isolate); \
- if (val.IsEmpty()) return Local<Object>(); \
+ if (val.IsEmpty()) \
+ return Local<Object>(); \
stats->Set(env->name ## _string(), val); \
}
X(dev)
#define X(name) \
{ \
Local<Value> val = Number::New(static_cast<double>(s->st_##name)); \
- if (val.IsEmpty()) return Local<Object>(); \
+ if (val.IsEmpty()) \
+ return Local<Object>(); \
stats->Set(env->name ## _string(), val); \
}
X(ino)
double msecs = static_cast<double>(s->st_##rec.tv_sec) * 1000; \
msecs += static_cast<double>(s->st_##rec.tv_nsec / 1000000); \
Local<Value> val = v8::Date::New(msecs); \
- if (val.IsEmpty()) return Local<Object>(); \
+ if (val.IsEmpty()) \
+ return Local<Object>(); \
stats->Set(env->name ## _string(), val); \
}
X(atime, atim)
static void Stat(const FunctionCallbackInfo<Value>& 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]);
static void LStat(const FunctionCallbackInfo<Value>& 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]);
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]);
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]);
static void ReadLink(const FunctionCallbackInfo<Value>& 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]);
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]);
static void Unlink(const FunctionCallbackInfo<Value>& 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]);
static void RMDir(const FunctionCallbackInfo<Value>& 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]);
static void ReadDir(const FunctionCallbackInfo<Value>& 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]);
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();
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);
}
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<uv_uid_t>(args[1]->Uint32Value());
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<uv_uid_t>(args[1]->Uint32Value());
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<double>(args[1]->NumberValue());
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<double>(args[1]->NumberValue());
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<Integer> nparsed_obj = Integer::New(nparsed, node_isolate);
// If there was a parse error in one of the callbacks
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_);
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;
}
virtual ~ObjectWrap() {
- if (persistent().IsEmpty()) return;
+ if (persistent().IsEmpty())
+ return;
assert(persistent().IsNearDeath());
persistent().ClearWeak();
persistent().Dispose();
assert(!persistent().IsEmpty());
assert(!persistent().IsWeak());
assert(refs_ > 0);
- if (--refs_ == 0) MakeWeak();
+ if (--refs_ == 0)
+ MakeWeak();
}
int refs_; // ro
OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof(info);
- if (GetVersionEx(&info) == 0) return;
+ if (GetVersionEx(&info) == 0)
+ return;
snprintf(release,
sizeof(release),
int count, i;
int err = uv_cpu_info(&cpu_infos, &count);
- if (err) return;
+ if (err)
+ return;
Local<Array> cpus = Array::New();
for (i = 0; i < count; i++) {
static void GetFreeMemory(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
double amount = uv_get_free_memory();
- if (amount < 0) return;
+ if (amount < 0)
+ return;
args.GetReturnValue().Set(amount);
}
static void GetTotalMemory(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
double amount = uv_get_total_memory();
- if (amount < 0) return;
+ if (amount < 0)
+ return;
args.GetReturnValue().Set(amount);
}
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);
}
const bool persistent = args[1]->BooleanValue();
const uint32_t interval = args[2]->Uint32Value();
- if (!persistent) uv_unref(reinterpret_cast<uv_handle_t*>(wrap->watcher_));
+ if (!persistent)
+ uv_unref(reinterpret_cast<uv_handle_t*>(wrap->watcher_));
uv_fs_poll_start(wrap->watcher_, Callback, *path, interval);
wrap->ClearWeak();
}
void StatWatcher::Stop() {
- if (!uv_is_active(reinterpret_cast<uv_handle_t*>(watcher_))) return;
+ if (!uv_is_active(reinterpret_cast<uv_handle_t*>(watcher_)))
+ return;
uv_fs_poll_stop(watcher_);
MakeWeak();
}
}
static void SetDictionary(ZCtx* ctx) {
- if (ctx->dictionary_ == NULL) return;
+ if (ctx->dictionary_ == NULL)
+ return;
ctx->err_ = Z_OK;
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);
}
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);
template <typename TypeName>
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<unsigned>(-1);
}
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;
}
bool StringBytes::IsValidString(Handle<String> 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;
}
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;
}
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;
}
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(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;
reinterpret_cast<const sockaddr*>(&addr),
AfterConnect);
req_wrap->Dispatched();
- if (err) delete req_wrap;
+ if (err)
+ delete req_wrap;
}
args.GetReturnValue().Set(err);
reinterpret_cast<const sockaddr*>(&addr),
AfterConnect);
req_wrap->Dispatched();
- if (err) delete req_wrap;
+ if (err)
+ delete req_wrap;
}
args.GetReturnValue().Set(err);
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:
} 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.
}
req_wrap->Dispatched();
- if (err) delete req_wrap;
+ if (err)
+ delete req_wrap;
args.GetReturnValue().Set(err);
}
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);
}
void ErrName(const FunctionCallbackInfo<Value>& 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));
}
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.