Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade cpplint #7462

Merged
merged 22 commits into from
Jun 29, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
04c723d
tools: update cpplint to r456
bnoordhuis Jun 28, 2016
fc10624
tools: disable unwanted cpplint rules again
bnoordhuis Jun 28, 2016
bb81d69
tools: add back --mode=tap to cpplint
bnoordhuis Jun 28, 2016
fadf66a
tools: allow cpplint to run outside git repo
bnoordhuis Jun 28, 2016
19ec5d7
src: fix build/c++tr1 cpplint warnings
bnoordhuis Jun 28, 2016
e9559d0
src: fix build/header_guard cpplint warnings
bnoordhuis Jun 28, 2016
29228c4
src: fix readability/braces cpplint warnings
bnoordhuis Jun 28, 2016
df3a192
src: fix readability/constructors cpplint warnings
bnoordhuis Jun 28, 2016
8e39522
src: fix readability/inheritance cpplint warnings
bnoordhuis Jun 28, 2016
0ba0eca
src: fix readability/namespace cpplint warnings
bnoordhuis Jun 28, 2016
d112df4
src: fix readability/nolint cpplint warnings
bnoordhuis Jun 28, 2016
1243134
src: fix runtime/indentation_namespace warnings
bnoordhuis Jun 28, 2016
ae0c650
src: fix runtime/int cpplint warnings
bnoordhuis Jun 28, 2016
2f2002a
src: fix runtime/references cpplint warnings
bnoordhuis Jun 28, 2016
0daffdf
src: fix whitespace/blank_line cpplint warnings
bnoordhuis Jun 28, 2016
97aeb0a
src: fix whitespace/indent cpplint warnings
bnoordhuis Jun 28, 2016
f52e26f
build: remove unused files from CPPLINT_FILES
bnoordhuis Jun 28, 2016
a26c3cd
src: lint node_win32_perfctr_provider.cc
bnoordhuis Jun 28, 2016
f1d2792
src: lint node_lttng_tp.h
bnoordhuis Jun 28, 2016
dbe4b58
src: lint v8abbr.h
bnoordhuis Jun 28, 2016
9a6439a
tools: fix -Wunused-variable warning
bnoordhuis Jun 28, 2016
f8d3f6f
src: remove obsolete NOLINT comments
bnoordhuis Jun 28, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
src: fix runtime/int cpplint warnings
PR-URL: #7462
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
bnoordhuis committed Jun 28, 2016
commit ae0c6504b216dc4574c1b20b65ab179181328d69
48 changes: 23 additions & 25 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static int CryptoPemCallback(char *buf, int size, int rwflag, void *u) {


void ThrowCryptoError(Environment* env,
unsigned long err,
unsigned long err, // NOLINT(runtime/int)
const char* default_message = nullptr) {
HandleScope scope(env->isolate());
if (err != 0 || default_message == nullptr) {
Expand Down Expand Up @@ -458,7 +458,7 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {

if (!key) {
BIO_free_all(bio);
unsigned long err = ERR_get_error();
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
if (!err) {
return env->ThrowError("PEM_read_bio_PrivateKey");
}
Expand All @@ -470,7 +470,7 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
BIO_free_all(bio);

if (!rv) {
unsigned long err = ERR_get_error();
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
if (!err)
return env->ThrowError("SSL_CTX_use_PrivateKey");
return ThrowCryptoError(env, err);
Expand Down Expand Up @@ -588,7 +588,7 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx,

X509* extra = nullptr;
int ret = 0;
unsigned long err = 0;
unsigned long err = 0; // NOLINT(runtime/int)

// Read extra certs
STACK_OF(X509)* extra_certs = sk_X509_new_null();
Expand Down Expand Up @@ -664,7 +664,7 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
BIO_free_all(bio);

if (!rv) {
unsigned long err = ERR_get_error();
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
if (!err) {
return env->ThrowError("SSL_CTX_use_certificate_chain");
}
Expand Down Expand Up @@ -873,7 +873,9 @@ void SecureContext::SetOptions(const FunctionCallbackInfo<Value>& args) {
return sc->env()->ThrowTypeError("Options must be an integer value");
}

SSL_CTX_set_options(sc->ctx_, static_cast<long>(args[0]->IntegerValue()));
SSL_CTX_set_options(
sc->ctx_,
static_cast<long>(args[0]->IntegerValue())); // NOLINT(runtime/int)
}


Expand Down Expand Up @@ -1016,7 +1018,7 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
delete[] pass;

if (!ret) {
unsigned long err = ERR_get_error();
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
const char* str = ERR_reason_error_string(err);
return env->ThrowError(str);
}
Expand Down Expand Up @@ -1458,7 +1460,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
String::kNormalString, mem->length));
(void) BIO_reset(bio);

unsigned long exponent_word = BN_get_word(rsa->e);
BN_ULONG exponent_word = BN_get_word(rsa->e);
BIO_printf(bio, "0x%lx", exponent_word);

BIO_get_mem_ptr(bio, &mem);
Expand Down Expand Up @@ -1928,7 +1930,8 @@ void SSLWrap<Base>::VerifyError(const FunctionCallbackInfo<Value>& args) {
// XXX(bnoordhuis) The UNABLE_TO_GET_ISSUER_CERT error when there is no
// peer certificate is questionable but it's compatible with what was
// here before.
long x509_verify_error = X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT;
long x509_verify_error = // NOLINT(runtime/int)
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT;
if (X509* peer_cert = SSL_get_peer_certificate(w->ssl_)) {
X509_free(peer_cert);
x509_verify_error = SSL_get_verify_result(w->ssl_);
Expand Down Expand Up @@ -2157,11 +2160,6 @@ void SSLWrap<Base>::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
#endif // OPENSSL_NPN_NEGOTIATED

#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
typedef struct tlsextalpnctx_st {
unsigned char* data;
unsigned short len;
} tlsextalpnctx;

template <class Base>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this related to lint changes, or just dead code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter was complaining about the unsigned short. I figured if it's unused I might as well remove it instead of adding a NOLINT.

int SSLWrap<Base>::SelectALPNCallback(SSL* s,
const unsigned char** out,
Expand Down Expand Up @@ -2401,7 +2399,7 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
if (rv)
rv = w->SetCACerts(sc);
if (!rv) {
unsigned long err = ERR_get_error();
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
if (!err)
return env->ThrowError("CertCbDone");
return ThrowCryptoError(env, err);
Expand Down Expand Up @@ -2839,7 +2837,7 @@ void Connection::New(const FunctionCallbackInfo<Value>& args) {
SSL_set_bio(conn->ssl_, conn->bio_read_, conn->bio_write_);

#ifdef SSL_MODE_RELEASE_BUFFERS
long mode = SSL_get_mode(conn->ssl_);
long mode = SSL_get_mode(conn->ssl_); // NOLINT(runtime/int)
SSL_set_mode(conn->ssl_, mode | SSL_MODE_RELEASE_BUFFERS);
#endif

Expand Down Expand Up @@ -3838,7 +3836,7 @@ void SignBase::CheckThrow(SignBase::Error error) {
case kSignPrivateKey:
case kSignPublicKey:
{
unsigned long err = ERR_get_error();
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
if (err)
return ThrowCryptoError(env(), err);
switch (error) {
Expand Down Expand Up @@ -5415,11 +5413,11 @@ class RandomBytesRequest : public AsyncWrap {
size_ = 0;
}

inline unsigned long error() const {
inline unsigned long error() const { // NOLINT(runtime/int)
return error_;
}

inline void set_error(unsigned long err) {
inline void set_error(unsigned long err) { // NOLINT(runtime/int)
error_ = err;
}

Expand All @@ -5428,7 +5426,7 @@ class RandomBytesRequest : public AsyncWrap {
uv_work_t work_req_;

private:
unsigned long error_;
unsigned long error_; // NOLINT(runtime/int)
size_t size_;
char* data_;
};
Expand All @@ -5446,9 +5444,9 @@ void RandomBytesWork(uv_work_t* work_req) {

// RAND_bytes() returns 0 on error.
if (r == 0) {
req->set_error(ERR_get_error());
req->set_error(ERR_get_error()); // NOLINT(runtime/int)
} else if (r == -1) {
req->set_error(static_cast<unsigned long>(-1));
req->set_error(static_cast<unsigned long>(-1)); // NOLINT(runtime/int)
}
}

Expand All @@ -5458,7 +5456,7 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
if (req->error()) {
char errmsg[256] = "Operation not supported";

if (req->error() != static_cast<unsigned long>(-1))
if (req->error() != static_cast<unsigned long>(-1)) // NOLINT(runtime/int)
ERR_error_string_n(req->error(), errmsg, sizeof errmsg);

argv[0] = Exception::Error(OneByteString(req->env()->isolate(), errmsg));
Expand Down Expand Up @@ -5797,7 +5795,7 @@ void InitCryptoOnce() {

#ifdef NODE_FIPS_MODE
/* Override FIPS settings in cnf file, if needed. */
unsigned long err = 0;
unsigned long err = 0; // NOLINT(runtime/int)
if (enable_fips_crypto || force_fips_crypto) {
if (0 == FIPS_mode() && !FIPS_mode_set(1)) {
err = ERR_get_error();
Expand Down Expand Up @@ -5879,7 +5877,7 @@ void SetFipsCrypto(const FunctionCallbackInfo<Value>& args) {
return env->ThrowError(
"Cannot set FIPS mode, it was forced with --force-fips at startup.");
} else if (!FIPS_mode_set(mode)) {
unsigned long err = ERR_get_error();
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
return ThrowCryptoError(env, err);
}
#else
Expand Down
5 changes: 3 additions & 2 deletions src/node_crypto_bio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ int NodeBIO::Gets(BIO* bio, char* out, int size) {
}


long NodeBIO::Ctrl(BIO* bio, int cmd, long num, void* ptr) {
long NodeBIO::Ctrl(BIO* bio, int cmd, long num, // NOLINT(runtime/int)
void* ptr) {
NodeBIO* nbio;
long ret;
long ret; // NOLINT(runtime/int)

nbio = FromBIO(bio);
ret = 1;
Expand Down
3 changes: 2 additions & 1 deletion src/node_crypto_bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class NodeBIO {
static int Write(BIO* bio, const char* data, int len);
static int Puts(BIO* bio, const char* str);
static int Gets(BIO* bio, char* out, int size);
static long Ctrl(BIO* bio, int cmd, long num, void* ptr);
static long Ctrl(BIO* bio, int cmd, long num, // NOLINT(runtime/int)
void* ptr);

// Enough to handle the most of the client hellos
static const size_t kInitialBufferLength = 1024;
Expand Down
2 changes: 1 addition & 1 deletion src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void TLSWrap::InitSSL() {
SSL_set_verify(ssl_, SSL_VERIFY_NONE, crypto::VerifyCallback);

#ifdef SSL_MODE_RELEASE_BUFFERS
long mode = SSL_get_mode(ssl_);
long mode = SSL_get_mode(ssl_); // NOLINT(runtime/int)
SSL_set_mode(ssl_, mode | SSL_MODE_RELEASE_BUFFERS);
#endif // SSL_MODE_RELEASE_BUFFERS

Expand Down