From 255d3a0a292825f2da3e16e0c6f6a781135f9997 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 26 Jan 2023 15:39:23 +1100 Subject: [PATCH] Fix C++ "init-statement in selection" warning --- example/cbor-to-json/cbor-to-json.cc | 3 ++- example/json-to-cbor/json-to-cbor.cc | 3 ++- example/jsonfindptrs/jsonfindptrs.cc | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/example/cbor-to-json/cbor-to-json.cc b/example/cbor-to-json/cbor-to-json.cc index 1ce64121..467b5cbb 100644 --- a/example/cbor-to-json/cbor-to-json.cc +++ b/example/cbor-to-json/cbor-to-json.cc @@ -786,7 +786,8 @@ compute_exit_code(std::string status_msg) { // (other non-zero exit codes). Specifically, exit code 2 for internal // invariant violation, exit code 139 (which is 128 + SIGSEGV on x86_64 // linux) for a segmentation fault (e.g. null pointer dereference). - if (size_t i = status_msg.find('='); i != std::string::npos) { + size_t i = status_msg.find('='); + if (i != std::string::npos) { status_msg = status_msg.substr(0, i); } return (status_msg.find("internal error:") != std::string::npos) ? 2 : 1; diff --git a/example/json-to-cbor/json-to-cbor.cc b/example/json-to-cbor/json-to-cbor.cc index ab955831..7462f137 100644 --- a/example/json-to-cbor/json-to-cbor.cc +++ b/example/json-to-cbor/json-to-cbor.cc @@ -381,7 +381,8 @@ compute_exit_code(std::string status_msg) { // (other non-zero exit codes). Specifically, exit code 2 for internal // invariant violation, exit code 139 (which is 128 + SIGSEGV on x86_64 // linux) for a segmentation fault (e.g. null pointer dereference). - if (size_t i = status_msg.find('='); i != std::string::npos) { + size_t i = status_msg.find('='); + if (i != std::string::npos) { status_msg = status_msg.substr(0, i); } return (status_msg.find("internal error:") != std::string::npos) ? 2 : 1; diff --git a/example/jsonfindptrs/jsonfindptrs.cc b/example/jsonfindptrs/jsonfindptrs.cc index df717eb8..ca6d1e80 100644 --- a/example/jsonfindptrs/jsonfindptrs.cc +++ b/example/jsonfindptrs/jsonfindptrs.cc @@ -593,7 +593,8 @@ compute_exit_code(std::string status_msg) { // (other non-zero exit codes). Specifically, exit code 2 for internal // invariant violation, exit code 139 (which is 128 + SIGSEGV on x86_64 // linux) for a segmentation fault (e.g. null pointer dereference). - if (size_t i = status_msg.find('='); i != std::string::npos) { + size_t i = status_msg.find('='); + if (i != std::string::npos) { status_msg = status_msg.substr(0, i); } return (status_msg.find("internal error:") != std::string::npos) ? 2 : 1;