From bd9b776c47fef741587b3c9dba0aa020a07a071f Mon Sep 17 00:00:00 2001 From: Uwe Seimet <48174652+uweseimet@users.noreply.github.com> Date: Sun, 1 Oct 2023 23:50:30 +0200 Subject: [PATCH] Fix block size evaluation (#1212) (#1213) * Fix block size evaluation (#1212) --- cpp/piscsi/piscsi_core.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cpp/piscsi/piscsi_core.cpp b/cpp/piscsi/piscsi_core.cpp index ff6ecc18..c5391ce0 100644 --- a/cpp/piscsi/piscsi_core.cpp +++ b/cpp/piscsi/piscsi_core.cpp @@ -157,7 +157,6 @@ void Piscsi::TerminationHandler(int) Piscsi::optargs_type Piscsi::ParseArguments(const vector& args, int& port) const { optargs_type optargs; - int block_size = 0; string name; opterr = 1; @@ -168,6 +167,7 @@ Piscsi::optargs_type Piscsi::ParseArguments(const vector& args, int& por // the 'bus' object is created and configured case 'i': case 'I': + case 'b': case 'd': case 'D': case 'R': @@ -182,13 +182,6 @@ Piscsi::optargs_type Piscsi::ParseArguments(const vector& args, int& por continue; } - case 'b': { - if (!GetAsUnsignedInt(optarg, block_size)) { - throw parser_exception("Invalid block size " + string(optarg)); - } - continue; - } - case 'L': current_log_level = optarg; continue; @@ -220,7 +213,7 @@ Piscsi::optargs_type Piscsi::ParseArguments(const vector& args, int& por } if (optopt) { - throw parser_exception("Praser error"); + throw parser_exception("Parser error"); } } @@ -253,6 +246,12 @@ void Piscsi::CreateInitialDevices(const optargs_type& optargs) const id_and_lun = value; continue; + case 'b': + if (!GetAsUnsignedInt(value, block_size)) { + throw parser_exception("Invalid block size " + value); + } + continue; + case 'z': locale = value.c_str(); continue;