Skip to content

Commit f97b560

Browse files
committed
FIX: Fix cppcheck warnings
1 parent d9e31d2 commit f97b560

File tree

5 files changed

+8
-16
lines changed

5 files changed

+8
-16
lines changed

.github/workflows/build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
sudo apt-get install libpcre3 libpcre3-dev libzstd-dev ninja-build
2525
- name: Install cppcheck
2626
run: |
27-
git clone https://github.com/danmar/cppcheck.git --branch 2.14.1
27+
git clone https://github.com/danmar/cppcheck.git --branch 2.17.1
2828
cd cppcheck
2929
cmake -S. -B build \
3030
-DCMAKE_BUILD_TYPE=Release \

include/databento/detail/dbn_buffer_decoder.hpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "databento/detail/buffer.hpp"
88
#include "databento/detail/zstd_stream.hpp"
9-
#include "databento/ireadable.hpp"
109
#include "databento/record.hpp"
1110
#include "databento/timeseries.hpp"
1211

@@ -18,7 +17,8 @@ class DbnBufferDecoder {
1817
const RecordCallback& record_callback)
1918
: metadata_callback_{metadata_callback},
2019
record_callback_{record_callback},
21-
zstd_stream_{InitZstdBuffer()} {}
20+
zstd_stream_{std::make_unique<Buffer>()},
21+
zstd_buffer_{static_cast<Buffer*>(zstd_stream_.Input())} {}
2222

2323
KeepGoing Process(const char* data, std::size_t length);
2424

@@ -29,12 +29,6 @@ class DbnBufferDecoder {
2929
Records,
3030
};
3131

32-
std::unique_ptr<IReadable> InitZstdBuffer() {
33-
auto zstd_buffer = std::make_unique<Buffer>();
34-
zstd_buffer_ = zstd_buffer.get();
35-
return zstd_buffer;
36-
}
37-
3832
const MetadataCallback& metadata_callback_;
3933
const RecordCallback& record_callback_;
4034
ZstdDecodeStream zstd_stream_;
@@ -43,7 +37,7 @@ class DbnBufferDecoder {
4337
std::size_t bytes_needed_{};
4438
alignas(RecordHeader) std::array<std::byte, kMaxRecordLen> compat_buffer_{};
4539
std::uint8_t input_version_{};
46-
bool ts_out_;
40+
bool ts_out_{};
4741
DecoderState state_{DecoderState::Init};
4842
};
4943
} // namespace databento::detail

include/databento/detail/zstd_stream.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class ZstdDecodeStream : public IReadable {
2323
// return 0 if the end of the stream is reached.
2424
std::size_t ReadSome(std::byte* buffer, std::size_t max_length) override;
2525

26+
IReadable* Input() const { return input_.get(); }
27+
2628
private:
2729
std::unique_ptr<IReadable> input_;
2830
std::unique_ptr<ZSTD_DStream, std::size_t (*)(ZSTD_DStream*)> z_dstream_;

src/dbn_decoder.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using databento::DbnDecoder;
2121
namespace {
2222
template <typename T>
2323
T Consume(const std::byte*& buf) {
24-
const auto res = *reinterpret_cast<const T*>(&*buf);
24+
const auto res = *reinterpret_cast<const T*>(buf);
2525
buf += sizeof(T);
2626
return res;
2727
}
@@ -34,7 +34,7 @@ std::uint8_t Consume(const std::byte*& buf) {
3434
}
3535

3636
const char* Consume(const std::byte*& buf, const std::ptrdiff_t num_bytes) {
37-
const auto* pos = &*buf;
37+
const auto* pos = buf;
3838
buf += num_bytes;
3939
return reinterpret_cast<const char*>(pos);
4040
}

src/historical.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "databento/constants.hpp"
1616
#include "databento/datetime.hpp"
17-
#include "databento/dbn_decoder.hpp"
1817
#include "databento/dbn_file_store.hpp"
1918
#include "databento/detail/dbn_buffer_decoder.hpp"
2019
#include "databento/detail/json_helpers.hpp"
@@ -24,7 +23,6 @@
2423
#include "databento/log.hpp"
2524
#include "databento/metadata.hpp"
2625
#include "databento/timeseries.hpp"
27-
#include "dbn_constants.hpp"
2826

2927
using databento::Historical;
3028

@@ -676,7 +674,6 @@ double Historical::MetadataGetCost(
676674
const std::string& dataset, const DateTimeRange<UnixNanos>& datetime_range,
677675
const std::vector<std::string>& symbols, Schema schema, FeedMode mode,
678676
SType stype_in, std::uint64_t limit) {
679-
static const std::string kPath = ::BuildMetadataPath(".get_cost");
680677
httplib::Params params{
681678
{"dataset", dataset},
682679
{"start", ToString(datetime_range.start)},
@@ -693,7 +690,6 @@ double Historical::MetadataGetCost(
693690
const DateTimeRange<std::string>& datetime_range,
694691
const std::vector<std::string>& symbols, Schema schema, FeedMode mode,
695692
SType stype_in, std::uint64_t limit) {
696-
static const std::string kPath = ::BuildMetadataPath(".get_cost");
697693
httplib::Params params{
698694
{"dataset", dataset},
699695
{"start", datetime_range.start},

0 commit comments

Comments
 (0)