Skip to content

Commit 2d57504

Browse files
danbevaddaleax
authored andcommitted
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 <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f516f68 commit 2d57504

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/node_buffer.cc

+9-9
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; \
@@ -496,9 +496,9 @@ void Copy(const FunctionCallbackInfo<Value> &args) {
496496
SPREAD_BUFFER_ARG(buffer_obj, ts_obj);
497497
SPREAD_BUFFER_ARG(target_obj, target);
498498

499-
size_t target_start;
500-
size_t source_start;
501-
size_t source_end;
499+
size_t target_start = 0;
500+
size_t source_start = 0;
501+
size_t source_end = 0;
502502

503503
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[2], 0, &target_start));
504504
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[3], 0, &source_start));
@@ -690,10 +690,10 @@ void CompareOffset(const FunctionCallbackInfo<Value> &args) {
690690
SPREAD_BUFFER_ARG(args[0], ts_obj);
691691
SPREAD_BUFFER_ARG(args[1], target);
692692

693-
size_t target_start;
694-
size_t source_start;
695-
size_t source_end;
696-
size_t target_end;
693+
size_t target_start = 0;
694+
size_t source_start = 0;
695+
size_t source_end = 0;
696+
size_t target_end = 0;
697697

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

0 commit comments

Comments
 (0)