Skip to content

Commit f9126bc

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

File tree

5 files changed

+11
-18
lines changed

5 files changed

+11
-18
lines changed

.github/workflows/cmake-windows.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,27 @@ on: [push, pull_request]
55
env:
66
BUILD_TYPE: RelWithDebInfo
77
CMAKE_BUILD_PARALLEL_LEVEL: 3
8-
VCPKG_MANIFEST_DIR: .github
9-
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/build/vcpkg_installed
108

119
jobs:
1210
build:
1311
runs-on: windows-latest
1412

1513
steps:
1614
- name: Checkout code
17-
uses: actions/checkout@v4
15+
uses: actions/checkout@v5
1816

1917
- name: Cache vcpkg
2018
uses: actions/cache@v4
2119
with:
2220
path: ${{ github.workspace }}/vcpkg_cache
23-
key: vcpkg-${{ hashFiles(format('{0}/vcpkg.json', env.VCPKG_MANIFEST_DIR)) }}
21+
key: vcpkg-${{ hashFiles('vcpkg.json') }}
2422

25-
- name: Prepare vcpkg and libraries
26-
uses: lukka/run-vcpkg@v11
27-
with:
28-
vcpkgJsonGlob: ${{ env.VCPKG_MANIFEST_DIR }}/vcpkg.json
29-
runVcpkgInstall: true
23+
- name: Configure CMake
3024
env:
3125
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
32-
33-
- name: Configure CMake
3426
run: |
3527
cmake -A x64 -S . -B build "-DCMAKE_BUILD_TYPE=${env:BUILD_TYPE}" `
36-
"-DCMAKE_TOOLCHAIN_FILE=${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" `
37-
"-DVCPKG_MANIFEST_DIR=${{ env.VCPKG_MANIFEST_DIR }}"
28+
"-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
3829
3930
- name: Build
4031
run: cmake --build build --config ${env:BUILD_TYPE}

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,
File renamed without changes.

0 commit comments

Comments
 (0)