diff --git a/cpp/piscsi/piscsi_service.cpp b/cpp/piscsi/piscsi_service.cpp index 897f250b91..700a86588e 100644 --- a/cpp/piscsi/piscsi_service.cpp +++ b/cpp/piscsi/piscsi_service.cpp @@ -122,7 +122,7 @@ PbCommand PiscsiService::ReadCommand(CommandContext& context) const PbCommand command; // Read magic string - vector magic(6); + array magic; const size_t bytes_read = context.GetSerializer().ReadBytes(fd, magic); if (!bytes_read) { return command; diff --git a/cpp/shared/protobuf_serializer.cpp b/cpp/shared/protobuf_serializer.cpp index ffca4e23b5..2c0599299a 100644 --- a/cpp/shared/protobuf_serializer.cpp +++ b/cpp/shared/protobuf_serializer.cpp @@ -3,7 +3,7 @@ // SCSI Target Emulator PiSCSI // for Raspberry Pi // -// Copyright (C) 2022 Uwe Seimet +// Copyright (C) 2022-2023 Uwe Seimet // //--------------------------------------------------------------------------- @@ -42,7 +42,7 @@ void ProtobufSerializer::SerializeMessage(int fd, const google::protobuf::Messag void ProtobufSerializer::DeserializeMessage(int fd, google::protobuf::Message& message) const { // Read the header with the size of the protobuf data - vector header_buf(4); + array header_buf; if (ReadBytes(fd, header_buf) < header_buf.size()) { throw io_exception("Invalid protobuf message header"); } @@ -64,7 +64,7 @@ void ProtobufSerializer::DeserializeMessage(int fd, google::protobuf::Message& m message.ParseFromString(data); } -size_t ProtobufSerializer::ReadBytes(int fd, vector& buf) const +size_t ProtobufSerializer::ReadBytes(int fd, span buf) const { size_t offset = 0; while (offset < buf.size()) { diff --git a/cpp/shared/protobuf_serializer.h b/cpp/shared/protobuf_serializer.h index b9a6730232..d4b2c18ef5 100644 --- a/cpp/shared/protobuf_serializer.h +++ b/cpp/shared/protobuf_serializer.h @@ -3,7 +3,7 @@ // SCSI Target Emulator PiSCSI // for Raspberry Pi // -// Copyright (C) 2022 Uwe Seimet +// Copyright (C) 2022-2023 Uwe Seimet // // Helper for serializing/deserializing protobuf messages // @@ -12,7 +12,7 @@ #pragma once #include "google/protobuf/message.h" -#include +#include using namespace std; @@ -25,5 +25,5 @@ class ProtobufSerializer void SerializeMessage(int, const google::protobuf::Message&) const; void DeserializeMessage(int, google::protobuf::Message&) const; - size_t ReadBytes(int, vector&) const; + size_t ReadBytes(int, span) const; };