Skip to content

Commit

Permalink
Replace vector by span
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Sep 7, 2023
1 parent 1969055 commit e294b30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cpp/piscsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SCSI Target Emulator PiSCSI
// for Raspberry Pi
//
// Copyright (C) 2022 Uwe Seimet
// Copyright (C) 2022-2023 Uwe Seimet
//
//---------------------------------------------------------------------------

Expand All @@ -13,7 +13,7 @@ using namespace std;

int main(int argc, char *argv[])
{
const vector<char *> args(argv, argv + argc);
vector<char *> args(argv, argv + argc);

return Piscsi().run(args);
}
6 changes: 3 additions & 3 deletions cpp/piscsi/piscsi_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using namespace piscsi_util;
using namespace protobuf_util;
using namespace scsi_defs;

void Piscsi::Banner(const vector<char *>& args) const
void Piscsi::Banner(span<char *> args) const
{
cout << piscsi_util::Banner("(Backend Service)");
cout << "Connection type: " << CONNECT_DESC << '\n' << flush;
Expand Down Expand Up @@ -139,7 +139,7 @@ void Piscsi::TerminationHandler(int)
// Process will terminate automatically
}

Piscsi::optargs_type Piscsi::ParseArguments(const vector<char *>& args, int& port) const
Piscsi::optargs_type Piscsi::ParseArguments(span<char *> args, int& port) const
{
optargs_type optargs;
int block_size = 0;
Expand Down Expand Up @@ -465,7 +465,7 @@ bool Piscsi::ExecuteCommand(const CommandContext& context, const PbCommand& comm
return true;
}

int Piscsi::run(const vector<char *>& args)
int Piscsi::run(span<char *> args)
{
GOOGLE_PROTOBUF_VERIFY_VERSION;

Expand Down
7 changes: 4 additions & 3 deletions cpp/piscsi/piscsi_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "piscsi/piscsi_image.h"
#include "piscsi/piscsi_response.h"
#include "generated/piscsi_interface.pb.h"
#include <span>
#include <vector>
#include <string>
#include <filesystem>
Expand All @@ -38,17 +39,17 @@ class Piscsi
Piscsi() = default;
~Piscsi() = default;

int run(const vector<char *>&);
int run(span<char *>);

private:

void Banner(const vector<char *>&) const;
void Banner(span<char *>) const;
bool InitBus() const;
static void Cleanup();
void ReadAccessToken(const path&) const;
void LogDevices(string_view) const;
static void TerminationHandler(int);
optargs_type ParseArguments(const vector<char *>&, int&) const;
optargs_type ParseArguments(span<char *>, int&) const;
void CreateInitialDevices(const optargs_type&) const;
void WaitForNotBusy() const;

Expand Down

0 comments on commit e294b30

Please sign in to comment.