From 1b16bb4e0887ca522f19ca547f09fd3f70cc653f Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Thu, 24 Nov 2022 08:51:29 +0100 Subject: [PATCH] address clang scan warning Change-Id: I6af3bd817e7c2d1f7c68ee463e27df42215072b5 --- src/pcm-raw.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/pcm-raw.cpp b/src/pcm-raw.cpp index 0ceb2d23..2596e4fc 100644 --- a/src/pcm-raw.cpp +++ b/src/pcm-raw.cpp @@ -1906,7 +1906,11 @@ int main(int argc, char* argv[]) argc--; string arg_value; - if (check_argument_equals(*argv, {"--help", "-h", "/h"})) + if (*argv == nullptr) + { + continue; + } + else if (check_argument_equals(*argv, {"--help", "-h", "/h"})) { print_usage(program); exit(EXIT_FAILURE); @@ -2034,7 +2038,13 @@ int main(int argc, char* argv[]) { argv++; argc--; - if (addEvents(PMUConfigs, *argv) == false) + const auto p = *argv; + if (p == nullptr) + { + cerr << "ERROR: no parameter value provided for 'el' option\n"; + exit(EXIT_FAILURE); + } + else if (addEvents(PMUConfigs, p) == false) { exit(EXIT_FAILURE); } @@ -2044,7 +2054,12 @@ int main(int argc, char* argv[]) { argv++; argc--; - if (addEvent(PMUConfigs[0], *argv) == false) + const auto p = *argv; + if (p == nullptr) + { + cerr << "ERROR: no parameter value provided for 'e' option\n"; + exit(EXIT_FAILURE); + } else if (addEvent(PMUConfigs[0], p) == false) { exit(EXIT_FAILURE); }