Skip to content

Commit a1390c2

Browse files
committed
Fix Coverity warnings
Signed-off-by: Raul Metsma <[email protected]>
1 parent 2288a02 commit a1390c2

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/libpcsc-cpp/tests/mock/test-byte-vector-string-operator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TEST(byte_vector_stringOperatorTest, appendsHexToNonEmptyString)
3131
byte_vector data = {0x12, 0x34, 0xAB, 0xFF};
3232
std::string prefix = "prefix-";
3333

34-
std::string result = prefix + data;
34+
std::string result = std::move(prefix) + data;
3535

3636
EXPECT_EQ(result, "prefix-1234abff");
3737
}
@@ -41,7 +41,7 @@ TEST(byte_vector_stringOperatorTest, appendsHexToEmptyString)
4141
byte_vector data = {0x01, 0xA0, 0xFF};
4242
std::string prefix;
4343

44-
std::string result = prefix + data;
44+
std::string result = std::move(prefix) + data;
4545

4646
EXPECT_EQ(result, "01a0ff");
4747
}
@@ -51,7 +51,7 @@ TEST(byte_vector_stringOperatorTest, handlesEmptyByteVector)
5151
byte_vector data;
5252
std::string prefix = "nothing-changes-";
5353

54-
std::string result = prefix + data;
54+
std::string result = std::move(prefix) + data;
5555

5656
EXPECT_EQ(result, "nothing-changes-");
5757
}

src/electronic-ids/pcsc/EIDThales.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ byte_vector EIDThales::getCertificateImpl(const SmartCard::Session& session,
6969
ElectronicID::PinInfo EIDThales::pinRetriesLeft(const SmartCard::Session& session,
7070
byte_type pinReference, bool pinActive) const
7171
{
72-
const auto GET_DATA = smartcard().protocol() == SmartCard::Protocol::T1
72+
const auto& GET_DATA = smartcard().protocol() == SmartCard::Protocol::T1
7373
? CommandApdu {0x00, 0xCB, 0x00, 0xFF, {0xA0, 0x03, 0x83, 0x01, pinReference}, 0x00}
7474
: CommandApdu {0x00, 0xCB, 0x00, 0xFF, {0xA0, 0x03, 0x83, 0x01, pinReference}};
7575
const auto response = session.transmit(GET_DATA);

src/electronic-ids/pcsc/LatEIDIDEMIAv2.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ TLV LatEIDIDEMIAV2::readEF_File(const SmartCard::Session& session, byte_vector f
117117
if (auto it = cache.find(file); it != cache.end()) {
118118
return TLV(it->second);
119119
}
120-
return TLV(cache[std::move(file)] = readFile(session, CommandApdu::selectEF(0x02, file)));
120+
auto value = readFile(session, CommandApdu::selectEF(0x02, file));
121+
auto it = cache.try_emplace(std::move(file), std::move(value)).first;
122+
return TLV(it->second);
121123
}
122124

123125
TLV LatEIDIDEMIAV2::readDCODInfo(const SmartCard::Session& session, byte_type type,

0 commit comments

Comments
 (0)