Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
# specific language governing permissions and limitations
# under the License.

name: "CodeQL quality configuration"
name: "CodeQL configuration"

paths-ignore:
# Third-party dependencies fetched by the C++ build, not our code.
- cpp/_codeql_build_dir
# CodeQL's C/C++ autobuild unpacks third-party dependencies here and compiles
# them as part of the analysis; they are not part of the TsFile source tree.
# The glob must end in /** — a bare directory name does not match a subtree.
- '**/_codeql_build_dir/**'
# Build-managed third-party sources extracted by the C++ build (gitignored).
- 'cpp/third_party/**'
2 changes: 1 addition & 1 deletion .github/workflows/codeql-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
config-file: ./.github/codeql/codeql-quality-config.yml
config-file: ./.github/codeql/codeql-config.yml
# Superset of the default suite: also runs maintainability/reliability queries.
queries: security-and-quality

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ jobs:
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# Shares the path exclusions with the quality scan: the C++ autobuild
# compiles third-party dependencies under cpp/_codeql_build_dir.
config-file: ./.github/codeql/codeql-config.yml
- name: Build Go for CodeQL
if: matrix.language == 'go' && matrix.build-mode == 'manual'
working-directory: go
Expand Down
12 changes: 5 additions & 7 deletions cpp/src/common/datatype/date_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ class DateConverter {
return E_INVALID_ARG;
}

const int64_t result =
static_cast<int64_t>(year) * 10000 + month * 100 + day;
if (result > INT32_MAX || result < INT32_MIN) {
return E_OUT_OF_RANGE;
}

out_int = static_cast<int32_t>(result);
// year is bounded to 1000..9999 above, so the packed value stays
// within int32 range.
const int32_t result =
static_cast<int32_t>(year * 10000 + month * 100 + day);
out_int = result;
return E_OK;
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/common/tsfile_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ struct ChunkGroupMeta {
class ITimeseriesIndex {
public:
ITimeseriesIndex() {}
~ITimeseriesIndex() {}
virtual ~ITimeseriesIndex() = default;
virtual common::SimpleList<ChunkMeta*>* get_chunk_meta_list() const {
return nullptr;
}
Expand Down
4 changes: 3 additions & 1 deletion cpp/src/encoding/ts2diff_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ inline int read_page_meta(common::ByteStream& in, PageMeta& meta) {
template <typename T>
class TS2DIFFDecoder : public Decoder {
public:
TS2DIFFDecoder() { reset(); }
// Qualified on purpose: a derived decoder is not constructed yet, so the
// base-state reset must not dispatch to the derived override.
TS2DIFFDecoder() { TS2DIFFDecoder::reset(); }
~TS2DIFFDecoder() override {}

void reset() override {
Expand Down
1 change: 1 addition & 0 deletions cpp/src/reader/qds_with_timegenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct SeriesScanStream {
ssi_(nullptr),
tsblock_(nullptr),
col_iter_(nullptr) {}
~SeriesScanStream() { destroy(); }
int init();
void destroy();
int64_t front();
Expand Down
14 changes: 12 additions & 2 deletions cpp/src/utils/date_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,18 @@ inline int32_t DaysSinceEpochToYYYYMMDD(int32_t days) {
epoch.tm_isdst = -1;
time_t epoch_t = mktime(&epoch);
time_t target_t = epoch_t + static_cast<time_t>(days) * 24 * 60 * 60;
std::tm* d = localtime(&target_t);
return (d->tm_year + 1900) * 10000 + (d->tm_mon + 1) * 100 + d->tm_mday;
std::tm target = {};
#ifdef _WIN32
if (localtime_s(&target, &target_t) != 0) {
return 0;
}
#else
if (localtime_r(&target_t, &target) == nullptr) {
return 0;
}
#endif
return (target.tm_year + 1900) * 10000 + (target.tm_mon + 1) * 100 +
target.tm_mday;
}

} // namespace common
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/writer/tsfile_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <chrono>
#include <iomanip>
#include <map>
#include <new>
#include <set>

#include "chunk_writer.h"
Expand Down Expand Up @@ -602,7 +603,7 @@ int TsFileWriter::ensure_aligned_value_chunk_writer(
if (measurement_schema->value_chunk_writer_ != nullptr) {
return E_OK;
}
ValueChunkWriter* value_chunk_writer = new ValueChunkWriter;
ValueChunkWriter* value_chunk_writer = new (std::nothrow) ValueChunkWriter;
if (IS_NULL(value_chunk_writer)) {
return E_OOM;
}
Expand Down
Loading