Skip to content

Commit f3edf29

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

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
@@ -71,7 +71,7 @@ byte_vector EIDThales::getCertificateImpl(const SmartCard::Session& session,
7171
ElectronicID::PinRetriesRemainingAndMax EIDThales::pinRetriesLeft(const SmartCard::Session& session,
7272
byte_type pinReference) const
7373
{
74-
const auto GET_DATA = smartcard().protocol() == SmartCard::Protocol::T1
74+
const auto& GET_DATA = smartcard().protocol() == SmartCard::Protocol::T1
7575
? CommandApdu {0x00, 0xCB, 0x00, 0xFF, {0xA0, 0x03, 0x83, 0x01, pinReference}, 0x00}
7676
: CommandApdu {0x00, 0xCB, 0x00, 0xFF, {0xA0, 0x03, 0x83, 0x01, pinReference}};
7777
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, inserted] = cache.try_emplace(std::move(file), std::move(value));
122+
return TLV(it->second);
121123
}
122124

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

0 commit comments

Comments
 (0)