Skip to content

Commit

Permalink
s2pexec: Log level and target can be set without a current command
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Oct 22, 2024
1 parent 1d461b3 commit a819b13
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions cpp/s2pexec/s2pexec_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,48 +223,46 @@ bool S2pExec::ParseArguments(span<char*> args)
throw parser_exception("Invalid log level: '" + log_level + "'");
}

if (!initiator.empty()) {
if (!GetAsUnsignedInt(initiator, initiator_id) || initiator_id > 7) {
throw parser_exception("Invalid initiator ID: '" + initiator + "' (0-7)");
}
}

if (!target.empty()) {
if (const string &error = ProcessId(target, target_id, target_lun); !error.empty()) {
throw parser_exception(error);
}
}

if (target_id == -1 && !reset_bus) {
throw parser_exception("Missing target ID");
}
if (!command.empty()) {
if (!initiator.empty()) {
if (!GetAsUnsignedInt(initiator, initiator_id) || initiator_id > 7) {
throw parser_exception("Invalid initiator ID: '" + initiator + "' (0-7)");
}
}

if (target_id == initiator_id) {
throw parser_exception("Target ID and initiator ID must not be identical");
}
if (target_id == -1 && !reset_bus) {
throw parser_exception("Missing target ID");
}

if (target_lun == -1) {
target_lun = 0;
}
if (target_id == initiator_id) {
throw parser_exception("Target ID and initiator ID must not be identical");
}

if (command.empty() && !reset_bus) {
throw parser_exception("Missing command block");
}
if (target_lun == -1) {
target_lun = 0;
}

if (!data.empty() && (!binary_input_filename.empty() || !hex_input_filename.empty())) {
throw parser_exception("An input file is not permitted when providing explicit data");
}
if (!data.empty() && (!binary_input_filename.empty() || !hex_input_filename.empty())) {
throw parser_exception("An input file is not permitted when providing explicit data");
}

if (!binary_input_filename.empty() && !hex_input_filename.empty()) {
throw parser_exception("There can only be a single input file");
}
if (!binary_input_filename.empty() && !hex_input_filename.empty()) {
throw parser_exception("There can only be a single input file");
}

if (!binary_output_filename.empty() && !hex_output_filename.empty()) {
throw parser_exception("There can only be a single output file");
}
if (!!binary_output_filename.empty() && !hex_output_filename.empty()) {
throw parser_exception("There can only be a single output file");
}

if (!GetAsUnsignedInt(tout, timeout) || !timeout) {
throw parser_exception("Invalid command timeout value: '" + tout + "'");
if ((!GetAsUnsignedInt(tout, timeout) || !timeout)) {
throw parser_exception("Invalid command timeout value: '" + tout + "'");
}
}

int buffer_size = DEFAULT_BUFFER_SIZE;
Expand Down Expand Up @@ -329,7 +327,9 @@ bool S2pExec::RunInteractive(bool in_process)
continue;
}

Run();
if (!command.empty()) {
Run();
}
}

CleanUp();
Expand Down

0 comments on commit a819b13

Please sign in to comment.