diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-01-23 15:04:02 +0300 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-02-07 07:33:11 +0300 |
commit | d310d8df62f9c05d07e68c4177f225e9dda72271 (patch) | |
tree | ca0ab5dfbb1ec53fb98c4286597905469e3dd7db /src/node_buffer.cc | |
parent | 93a57c3f1fe229f3d70357f5146293dc6b5dc3a1 (diff) |
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r-- | src/node_buffer.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 1aebe51e0bc..49a83907fe6 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -47,8 +47,8 @@ } while (0) \ #define SLICE_START_END(env, start_arg, end_arg, end_max) \ - size_t start; \ - size_t end; \ + size_t start = 0; \ + size_t end = 0; \ THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, start_arg, 0, &start)); \ THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, end_arg, end_max, &end)); \ if (end < start) end = start; \ @@ -498,9 +498,9 @@ void Copy(const FunctionCallbackInfo<Value> &args) { SPREAD_BUFFER_ARG(buffer_obj, ts_obj); SPREAD_BUFFER_ARG(target_obj, target); - size_t target_start; - size_t source_start; - size_t source_end; + size_t target_start = 0; + size_t source_start = 0; + size_t source_end = 0; THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[2], 0, &target_start)); THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[3], 0, &source_start)); @@ -692,10 +692,10 @@ void CompareOffset(const FunctionCallbackInfo<Value> &args) { SPREAD_BUFFER_ARG(args[0], ts_obj); SPREAD_BUFFER_ARG(args[1], target); - size_t target_start; - size_t source_start; - size_t source_end; - size_t target_end; + size_t target_start = 0; + size_t source_start = 0; + size_t source_end = 0; + size_t target_end = 0; THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[2], 0, &target_start)); THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[3], 0, &source_start)); |