From 3b1c19f90a701b3f4729f8d1c2c0896b021e7b0f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 13:13:58 +0200 Subject: [PATCH] src: initialize encoding_ data member Pointed out by Coverity. Not really a bug because it's assigned before use but explicit assignment in the constructor is more obviously correct. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/fs_event_wrap.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 10af967def..cf9559df9d 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -34,6 +34,8 @@ class FSEventWrap: public HandleWrap { size_t self_size() const override { return sizeof(*this); } private: + static const encoding kDefaultEncoding = UTF8; + FSEventWrap(Environment* env, Local object); ~FSEventWrap() override; @@ -41,8 +43,8 @@ class FSEventWrap: public HandleWrap { int status); uv_fs_event_t handle_; - bool initialized_; - enum encoding encoding_; + bool initialized_ = false; + enum encoding encoding_ = kDefaultEncoding; }; @@ -50,9 +52,7 @@ FSEventWrap::FSEventWrap(Environment* env, Local object) : HandleWrap(env, object, reinterpret_cast(&handle_), - AsyncWrap::PROVIDER_FSEVENTWRAP) { - initialized_ = false; -} + AsyncWrap::PROVIDER_FSEVENTWRAP) {} FSEventWrap::~FSEventWrap() { @@ -101,7 +101,7 @@ void FSEventWrap::Start(const FunctionCallbackInfo& args) { if (args[2]->IsTrue()) flags |= UV_FS_EVENT_RECURSIVE; - wrap->encoding_ = ParseEncoding(env->isolate(), args[3], UTF8); + wrap->encoding_ = ParseEncoding(env->isolate(), args[3], kDefaultEncoding); int err = uv_fs_event_init(wrap->env()->event_loop(), &wrap->handle_); if (err == 0) {