From 902ba0ecb46c97b1cc3b80ee6ed2247a302e0fb9 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 6 Oct 2018 15:58:04 -0400 Subject: [PATCH] src: reduce variable scope in module_wrap.cc PR-URL: https://github.com/nodejs/node/pull/23297 Reviewed-By: Anna Henningsen Reviewed-By: Joyee Cheung Reviewed-By: Refael Ackermann Reviewed-By: Gabriel Schulhof Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- src/module_wrap.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 4b60b6b8e4bb0e..816c68d55d16ce 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -433,16 +433,15 @@ std::string ReadFile(uv_file file) { uv_fs_t req; char buffer_memory[4096]; uv_buf_t buf = uv_buf_init(buffer_memory, sizeof(buffer_memory)); - int r; do { - r = uv_fs_read(uv_default_loop(), - &req, - file, - &buf, - 1, - contents.length(), // offset - nullptr); + const int r = uv_fs_read(uv_default_loop(), + &req, + file, + &buf, + 1, + contents.length(), // offset + nullptr); uv_fs_req_cleanup(&req); if (r <= 0)