Skip to content

Commit fe74283

Browse files
committed
Fix a few compiler warnings...
1 parent a601766 commit fe74283

6 files changed

Lines changed: 101 additions & 35 deletions

File tree

src/node_buffer.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,20 @@ Handle<Value> Buffer::Base64Slice(const Arguments &args) {
258258

259259
c = bitbuf[0] >> 2;
260260
assert(c < 64);
261-
out[j++] = base64_table[c];
261+
out[j++] = base64_table[(int)c];
262262
assert(j < out_len);
263263

264264
c = ((bitbuf[0] & 0x03) << 4) | (bitbuf[1] >> 4);
265265
assert(c < 64);
266-
out[j++] = base64_table[c];
266+
out[j++] = base64_table[(int)c];
267267
assert(j < out_len);
268268

269269
if (b1_oob) {
270270
out[j++] = '=';
271271
} else {
272272
c = ((bitbuf[1] & 0x0F) << 2) | (bitbuf[2] >> 6);
273273
assert(c < 64);
274-
out[j++] = base64_table[c];
274+
out[j++] = base64_table[(int)c];
275275
}
276276
assert(j < out_len);
277277

@@ -280,7 +280,7 @@ Handle<Value> Buffer::Base64Slice(const Arguments &args) {
280280
} else {
281281
c = bitbuf[2] & 0x3F;
282282
assert(c < 64);
283-
out[j++] = base64_table[c];
283+
out[j++] = base64_table[(int)c];
284284
}
285285
assert(j <= out_len);
286286
}
@@ -426,12 +426,12 @@ Handle<Value> Buffer::AsciiWrite(const Arguments &args) {
426426
Handle<Value> Buffer::Base64Write(const Arguments &args) {
427427
HandleScope scope;
428428

429-
assert(unbase64_table['/'] == 63);
430-
assert(unbase64_table['+'] == 62);
431-
assert(unbase64_table['T'] == 19);
432-
assert(unbase64_table['Z'] == 25);
433-
assert(unbase64_table['t'] == 45);
434-
assert(unbase64_table['z'] == 51);
429+
assert(unbase64_table[(int)'/'] == 63);
430+
assert(unbase64_table[(int)'+'] == 62);
431+
assert(unbase64_table[(int)'T'] == 19);
432+
assert(unbase64_table[(int)'Z'] == 25);
433+
assert(unbase64_table[(int)'t'] == 45);
434+
assert(unbase64_table[(int)'z'] == 51);
435435

436436
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
437437

@@ -468,18 +468,18 @@ Handle<Value> Buffer::Base64Write(const Arguments &args) {
468468
while (src < srcEnd) {
469469
const int remaining = srcEnd - src;
470470
if (remaining == 0 || *src == '=') break;
471-
a = unbase64_table[*src++];
471+
a = unbase64_table[(int)*src++];
472472

473473
if (remaining == 1 || *src == '=') break;
474-
b = unbase64_table[*src++];
474+
b = unbase64_table[(int)*src++];
475475
*dst++ = (a << 2) | ((b & 0x30) >> 4);
476476

477477
if (remaining == 2 || *src == '=') break;
478-
c = unbase64_table[*src++];
478+
c = unbase64_table[(int)*src++];
479479
*dst++ = ((b & 0x0F) << 4) | ((c & 0x3C) >> 2);
480480

481481
if (remaining == 3 || *src == '=') break;
482-
d = unbase64_table[*src++];
482+
d = unbase64_table[(int)*src++];
483483
*dst++ = ((c & 0x03) << 6) | (d & 0x3F);
484484
}
485485

src/node_crypto.cc

Lines changed: 83 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static Persistent<String> version_symbol;
3131

3232

3333
static int verify_callback(int ok, X509_STORE_CTX *ctx) {
34+
assert(ok);
3435
return(1); // Ignore errors by now. VerifyPeer will catch them by using SSL_get_verify_result.
3536
}
3637

@@ -693,7 +694,8 @@ void base64(unsigned char *input, int length, char** buf64, int* buf64_len) {
693694
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
694695
len = BIO_write(b64, input, length);
695696
assert(len == length);
696-
BIO_flush(b64);
697+
int r = BIO_flush(b64);
698+
assert(r == 1);
697699
BIO_get_mem_ptr(b64, &bptr);
698700

699701
*buf64_len = bptr->length;
@@ -804,7 +806,7 @@ int local_EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx,
804806
return(0);
805807
}
806808

807-
if (b > (sizeof(ctx->final) / sizeof(ctx->final[0]))) {
809+
if (b > (int)(sizeof(ctx->final) / sizeof(ctx->final[0]))) {
808810
EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT);
809811
return(0);
810812
}
@@ -961,6 +963,10 @@ class Cipher : public ObjectWrap {
961963

962964
delete [] key_buf;
963965

966+
if (!r) {
967+
return ThrowException(Exception::Error(String::New("CipherInit error")));
968+
}
969+
964970
return args.This();
965971
}
966972

@@ -1005,6 +1011,10 @@ class Cipher : public ObjectWrap {
10051011
delete [] key_buf;
10061012
delete [] iv_buf;
10071013

1014+
if (!r) {
1015+
return ThrowException(Exception::Error(String::New("CipherInitIv error")));
1016+
}
1017+
10081018
return args.This();
10091019
}
10101020

@@ -1023,21 +1033,27 @@ class Cipher : public ObjectWrap {
10231033
}
10241034

10251035
unsigned char *out=0;
1026-
int out_len=0;
1036+
int out_len=0, r;
10271037
if (Buffer::HasInstance(args[0])) {
10281038
Local<Object> buffer_obj = args[0]->ToObject();
10291039
char *buffer_data = Buffer::Data(buffer_obj);
10301040
size_t buffer_length = Buffer::Length(buffer_obj);
10311041

1032-
int r = cipher->CipherUpdate(buffer_data, buffer_length, &out, &out_len);
1042+
r = cipher->CipherUpdate(buffer_data, buffer_length, &out, &out_len);
10331043
} else {
10341044
char* buf = new char[len];
10351045
ssize_t written = DecodeWrite(buf, len, args[0], enc);
10361046
assert(written == len);
1037-
int r = cipher->CipherUpdate(buf, len,&out,&out_len);
1047+
r = cipher->CipherUpdate(buf, len,&out,&out_len);
10381048
delete [] buf;
10391049
}
10401050

1051+
if (!r) {
1052+
delete [] out;
1053+
Local<Value> exception = Exception::TypeError(String::New("DecipherUpdate fail"));
1054+
return ThrowException(exception);
1055+
}
1056+
10411057
Local<Value> outString;
10421058
if (out_len==0) {
10431059
outString=String::New("");
@@ -1308,6 +1324,10 @@ class Decipher : public ObjectWrap {
13081324

13091325
delete [] key_buf;
13101326

1327+
if (!r) {
1328+
return ThrowException(Exception::Error(String::New("DecipherInit error")));
1329+
}
1330+
13111331
return args.This();
13121332
}
13131333

@@ -1353,6 +1373,10 @@ class Decipher : public ObjectWrap {
13531373
delete [] key_buf;
13541374
delete [] iv_buf;
13551375

1376+
if (!r) {
1377+
return ThrowException(Exception::Error(String::New("DecipherInitIv error")));
1378+
}
1379+
13561380
return args.This();
13571381
}
13581382

@@ -1443,6 +1467,12 @@ class Decipher : public ObjectWrap {
14431467
int out_len=0;
14441468
int r = cipher->DecipherUpdate(buf, len, &out, &out_len);
14451469

1470+
if (!r) {
1471+
delete [] out;
1472+
Local<Value> exception = Exception::TypeError(String::New("DecipherUpdate fail"));
1473+
return ThrowException(exception);
1474+
}
1475+
14461476
Local<Value> outString;
14471477
if (out_len==0) {
14481478
outString=String::New("");
@@ -1491,9 +1521,7 @@ class Decipher : public ObjectWrap {
14911521

14921522
unsigned char* out_value;
14931523
int out_len;
1494-
char* out_hexdigest;
1495-
int out_hex_len;
1496-
Local<Value> outString ;
1524+
Local<Value> outString;
14971525

14981526
int r = cipher->DecipherFinal(&out_value, &out_len, false);
14991527

@@ -1536,8 +1564,6 @@ class Decipher : public ObjectWrap {
15361564

15371565
unsigned char* out_value;
15381566
int out_len;
1539-
char* out_hexdigest;
1540-
int out_hex_len;
15411567
Local<Value> outString ;
15421568

15431569
int r = cipher->DecipherFinal(&out_value, &out_len, true);
@@ -1677,6 +1703,10 @@ class Hmac : public ObjectWrap {
16771703

16781704
delete [] buf;
16791705

1706+
if (!r) {
1707+
return ThrowException(Exception::Error(String::New("hmac error")));
1708+
}
1709+
16801710
return args.This();
16811711
}
16821712

@@ -1692,21 +1722,28 @@ class Hmac : public ObjectWrap {
16921722
Local<Value> exception = Exception::TypeError(String::New("Bad argument"));
16931723
return ThrowException(exception);
16941724
}
1725+
1726+
int r;
16951727

16961728
if( Buffer::HasInstance(args[0])) {
16971729
Local<Object> buffer_obj = args[0]->ToObject();
16981730
char *buffer_data = Buffer::Data(buffer_obj);
16991731
size_t buffer_length = Buffer::Length(buffer_obj);
17001732

1701-
int r = hmac->HmacUpdate(buffer_data, buffer_length);
1733+
r = hmac->HmacUpdate(buffer_data, buffer_length);
17021734
} else {
17031735
char* buf = new char[len];
17041736
ssize_t written = DecodeWrite(buf, len, args[0], enc);
17051737
assert(written == len);
1706-
int r = hmac->HmacUpdate(buf, len);
1738+
r = hmac->HmacUpdate(buf, len);
17071739
delete [] buf;
17081740
}
17091741

1742+
if (!r) {
1743+
Local<Value> exception = Exception::TypeError(String::New("HmacUpdate fail"));
1744+
return ThrowException(exception);
1745+
}
1746+
17101747
return args.This();
17111748
}
17121749

@@ -1842,21 +1879,26 @@ class Hash : public ObjectWrap {
18421879
return ThrowException(exception);
18431880
}
18441881

1882+
int r;
18451883

18461884
if (Buffer::HasInstance(args[0])) {
18471885
Local<Object> buffer_obj = args[0]->ToObject();
18481886
char *buffer_data = Buffer::Data(buffer_obj);
18491887
size_t buffer_length = Buffer::Length(buffer_obj);
1850-
1851-
int r = hash->HashUpdate(buffer_data, buffer_length);
1888+
r = hash->HashUpdate(buffer_data, buffer_length);
18521889
} else {
18531890
char* buf = new char[len];
18541891
ssize_t written = DecodeWrite(buf, len, args[0], enc);
18551892
assert(written == len);
1856-
int r = hash->HashUpdate(buf, len);
1893+
r = hash->HashUpdate(buf, len);
18571894
delete[] buf;
18581895
}
18591896

1897+
if (!r) {
1898+
Local<Value> exception = Exception::TypeError(String::New("HashUpdate fail"));
1899+
return ThrowException(exception);
1900+
}
1901+
18601902
return args.This();
18611903
}
18621904

@@ -2000,6 +2042,10 @@ class Sign : public ObjectWrap {
20002042

20012043
bool r = sign->SignInit(*signType);
20022044

2045+
if (!r) {
2046+
return ThrowException(Exception::Error(String::New("SignInit error")));
2047+
}
2048+
20032049
return args.This();
20042050
}
20052051

@@ -2016,20 +2062,27 @@ class Sign : public ObjectWrap {
20162062
return ThrowException(exception);
20172063
}
20182064

2065+
int r;
2066+
20192067
if (Buffer::HasInstance(args[0])) {
20202068
Local<Object> buffer_obj = args[0]->ToObject();
20212069
char *buffer_data = Buffer::Data(buffer_obj);
20222070
size_t buffer_length = Buffer::Length(buffer_obj);
20232071

2024-
int r = sign->SignUpdate(buffer_data, buffer_length);
2072+
r = sign->SignUpdate(buffer_data, buffer_length);
20252073
} else {
20262074
char* buf = new char[len];
20272075
ssize_t written = DecodeWrite(buf, len, args[0], enc);
20282076
assert(written == len);
2029-
int r = sign->SignUpdate(buf, len);
2077+
r = sign->SignUpdate(buf, len);
20302078
delete [] buf;
20312079
}
20322080

2081+
if (!r) {
2082+
Local<Value> exception = Exception::TypeError(String::New("SignUpdate fail"));
2083+
return ThrowException(exception);
2084+
}
2085+
20332086
return args.This();
20342087
}
20352088

@@ -2201,6 +2254,10 @@ class Verify : public ObjectWrap {
22012254

22022255
bool r = verify->VerifyInit(*verifyType);
22032256

2257+
if (!r) {
2258+
return ThrowException(Exception::Error(String::New("VerifyInit error")));
2259+
}
2260+
22042261
return args.This();
22052262
}
22062263

@@ -2218,20 +2275,27 @@ class Verify : public ObjectWrap {
22182275
return ThrowException(exception);
22192276
}
22202277

2278+
int r;
2279+
22212280
if(Buffer::HasInstance(args[0])) {
22222281
Local<Object> buffer_obj = args[0]->ToObject();
22232282
char *buffer_data = Buffer::Data(buffer_obj);
22242283
size_t buffer_length = Buffer::Length(buffer_obj);
22252284

2226-
int r = verify->VerifyUpdate(buffer_data, buffer_length);
2285+
r = verify->VerifyUpdate(buffer_data, buffer_length);
22272286
} else {
22282287
char* buf = new char[len];
22292288
ssize_t written = DecodeWrite(buf, len, args[0], enc);
22302289
assert(written == len);
2231-
int r = verify->VerifyUpdate(buf, len);
2290+
r = verify->VerifyUpdate(buf, len);
22322291
delete [] buf;
22332292
}
22342293

2294+
if (!r) {
2295+
Local<Value> exception = Exception::TypeError(String::New("VerifyUpdate fail"));
2296+
return ThrowException(exception);
2297+
}
2298+
22352299
return args.This();
22362300
}
22372301

src/node_file.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ static Handle<Value> ReadDir(const Arguments& args) {
564564
char *name;
565565
int i = 0;
566566

567-
while (ent = readdir(dir)) {
567+
while ((ent = readdir(dir))) {
568568
name = ent->d_name;
569569

570570
if (name[0] != '.' || (name[1] && (name[1] != '.' || name[2]))) {

src/node_script.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Handle<Value> node::Script::CreateContext (const Arguments& args) {
107107
Local<Object> sandbox = args[0]->ToObject();
108108
Local<Array> keys = sandbox->GetPropertyNames();
109109

110-
for (int i = 0; i < keys->Length(); i++) {
110+
for (uint32_t i = 0; i < keys->Length(); i++) {
111111
Handle<String> key = keys->Get(Integer::New(i))->ToString();
112112
Handle<Value> value = sandbox->Get(key);
113113
context->Set(key, value);

src/node_signal_watcher.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void SignalWatcher::Callback(EV_P_ ev_signal *watcher, int revents) {
3030
SignalWatcher *w = static_cast<SignalWatcher*>(watcher->data);
3131

3232
assert(watcher == &w->watcher_);
33+
assert(revents == EV_SIGNAL);
3334

3435
HandleScope scope;
3536

wscript

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def configure(conf):
271271
# LFS
272272
conf.env.append_value('CPPFLAGS', '-D_LARGEFILE_SOURCE')
273273
conf.env.append_value('CPPFLAGS', '-D_FILE_OFFSET_BITS=64')
274+
conf.env.append_value('CPPFLAGS', '-DEV_MULTIPLICITY=0')
274275

275276
## needed for node_file.cc fdatasync
276277
## Strangely on OSX 10.6 the g++ doesn't see fdatasync but gcc does?

0 commit comments

Comments
 (0)