Skip to content

Commit

Permalink
[ci] more cpp lints (microsoft#2985)
Browse files Browse the repository at this point in the history
* fix

* Apply suggestions from code review

Co-authored-by: StrikerRUS <[email protected]>
  • Loading branch information
guolinke and StrikerRUS authored Apr 13, 2020
1 parent 6c19539 commit 5c0baf6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/LightGBM/utils/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ inline static unsigned CountDecimalDigit32(uint32_t n) {
1000000000
};
#ifdef _MSC_VER
// NOLINTNEXTLINE
unsigned long i = 0;
_BitScanReverse(&i, n | 1);
uint32_t t = (i + 1) * 1233 >> 12;
Expand Down
14 changes: 7 additions & 7 deletions src/io/dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ void Dataset::FinishLoad() {
void PushDataToMultiValBin(
data_size_t num_data, const std::vector<uint32_t> most_freq_bins,
const std::vector<uint32_t> offsets,
std::vector<std::vector<std::unique_ptr<BinIterator>>>& iters,
std::vector<std::vector<std::unique_ptr<BinIterator>>>* iters,
MultiValBin* ret) {
Common::FunctionTimer fun_time("Dataset::PushDataToMultiValBin",
global_timer);
Expand All @@ -444,12 +444,12 @@ void PushDataToMultiValBin(
std::vector<uint32_t> cur_data;
cur_data.reserve(most_freq_bins.size());
for (size_t j = 0; j < most_freq_bins.size(); ++j) {
iters[tid][j]->Reset(start);
(*iters)[tid][j]->Reset(start);
}
for (data_size_t i = start; i < end; ++i) {
cur_data.clear();
for (size_t j = 0; j < most_freq_bins.size(); ++j) {
auto cur_bin = iters[tid][j]->Get(i);
auto cur_bin = (*iters)[tid][j]->Get(i);
if (cur_bin == most_freq_bins[j]) {
continue;
}
Expand All @@ -467,11 +467,11 @@ void PushDataToMultiValBin(
0, num_data, 1024, [&](int tid, data_size_t start, data_size_t end) {
std::vector<uint32_t> cur_data(most_freq_bins.size(), 0);
for (size_t j = 0; j < most_freq_bins.size(); ++j) {
iters[tid][j]->Reset(start);
(*iters)[tid][j]->Reset(start);
}
for (data_size_t i = start; i < end; ++i) {
for (size_t j = 0; j < most_freq_bins.size(); ++j) {
auto cur_bin = iters[tid][j]->Get(i);
auto cur_bin = (*iters)[tid][j]->Get(i);
if (cur_bin == most_freq_bins[j]) {
cur_bin = 0;
} else {
Expand Down Expand Up @@ -528,7 +528,7 @@ MultiValBin* Dataset::GetMultiBinFromSparseFeatures() const {
std::unique_ptr<MultiValBin> ret;
ret.reset(MultiValBin::CreateMultiValBin(num_data_, offsets.back(),
num_feature, sum_sparse_rate));
PushDataToMultiValBin(num_data_, most_freq_bins, offsets, iters, ret.get());
PushDataToMultiValBin(num_data_, most_freq_bins, offsets, &iters, ret.get());
ret->FinishLoad();
return ret.release();
}
Expand Down Expand Up @@ -581,7 +581,7 @@ MultiValBin* Dataset::GetMultiBinFromAllFeatures() const {
ret.reset(MultiValBin::CreateMultiValBin(
num_data_, num_total_bin, static_cast<int>(most_freq_bins.size()),
1.0 - sum_dense_ratio));
PushDataToMultiValBin(num_data_, most_freq_bins, offsets, iters, ret.get());
PushDataToMultiValBin(num_data_, most_freq_bins, offsets, &iters, ret.get());
ret->FinishLoad();
return ret.release();
}
Expand Down
4 changes: 2 additions & 2 deletions src/io/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int Tree::Split(int leaf, int feature, int real_feature, uint32_t threshold_bin,
decision_type_[new_node_idx] = 0;
SetDecisionType(&decision_type_[new_node_idx], false, kCategoricalMask);
SetDecisionType(&decision_type_[new_node_idx], default_left, kDefaultLeftMask);
SetMissingType(&decision_type_[new_node_idx], missing_type);
SetMissingType(&decision_type_[new_node_idx], static_cast<int8_t>(missing_type));
threshold_in_bin_[new_node_idx] = threshold_bin;
threshold_[new_node_idx] = threshold_double;
++num_leaves_;
Expand All @@ -71,7 +71,7 @@ int Tree::SplitCategorical(int leaf, int feature, int real_feature, const uint32
int new_node_idx = num_leaves_ - 1;
decision_type_[new_node_idx] = 0;
SetDecisionType(&decision_type_[new_node_idx], true, kCategoricalMask);
SetMissingType(&decision_type_[new_node_idx], missing_type);
SetMissingType(&decision_type_[new_node_idx], static_cast<int8_t>(missing_type));
threshold_in_bin_[new_node_idx] = num_cat_;
threshold_[new_node_idx] = num_cat_;
++num_cat_;
Expand Down
1 change: 1 addition & 0 deletions src/network/socket_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class TcpSocket {
continue;
}
if (ifa->ifa_addr->sa_family == AF_INET) {
// NOLINTNEXTLINE
tmpAddrPtr = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
char addressBuffer[INET_ADDRSTRLEN];
inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
Expand Down

0 comments on commit 5c0baf6

Please sign in to comment.