Skip to content

Commit d310d8d

Browse files
committed
src: fix compiler warnings in node_buffer.cc
Currently the following compiler warnings are generated on Linux: ../src/node_buffer.cc: In function 'void node::Buffer::{anonymous}::StringSlice( const v8::FunctionCallbackInfo<v8::Value>&) [with node::encoding encoding = (node::encoding)1]': ../src/node_buffer.cc:54:20: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized] if (end < start) end = start; ^~~ ../src/node_buffer.cc:50:10: note: 'start' was declared here size_t start; ^~~~~ This commit initializes start and end to zero to avoid these warnings. PR-URL: #25665 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 93a57c3 commit d310d8d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/node_buffer.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
} while (0) \
4848

4949
#define SLICE_START_END(env, start_arg, end_arg, end_max) \
50-
size_t start; \
51-
size_t end; \
50+
size_t start = 0; \
51+
size_t end = 0; \
5252
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, start_arg, 0, &start)); \
5353
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, end_arg, end_max, &end)); \
5454
if (end < start) end = start; \
@@ -498,9 +498,9 @@ void Copy(const FunctionCallbackInfo<Value> &args) {
498498
SPREAD_BUFFER_ARG(buffer_obj, ts_obj);
499499
SPREAD_BUFFER_ARG(target_obj, target);
500500

501-
size_t target_start;
502-
size_t source_start;
503-
size_t source_end;
501+
size_t target_start = 0;
502+
size_t source_start = 0;
503+
size_t source_end = 0;
504504

505505
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[2], 0, &target_start));
506506
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[3], 0, &source_start));
@@ -692,10 +692,10 @@ void CompareOffset(const FunctionCallbackInfo<Value> &args) {
692692
SPREAD_BUFFER_ARG(args[0], ts_obj);
693693
SPREAD_BUFFER_ARG(args[1], target);
694694

695-
size_t target_start;
696-
size_t source_start;
697-
size_t source_end;
698-
size_t target_end;
695+
size_t target_start = 0;
696+
size_t source_start = 0;
697+
size_t source_end = 0;
698+
size_t target_end = 0;
699699

700700
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[2], 0, &target_start));
701701
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[3], 0, &source_start));

0 commit comments

Comments
 (0)