Skip to content

Commit 10eedbe

Browse files
junjieqimeta-codesync[bot]
authored andcommitted
Fix miscellaneous lint warnings (#5093)
Summary: Pull Request resolved: #5093 Fix remaining miscellaneous lint warnings across 10 files: - `facebook-hte-MultTypeDeclaration`: Split mixed-type declaration in AutoTune.cpp - `facebook-hte-IdenticalOperands`: Rename variable in build.cpp to avoid false positive - `facebook-hte-BadImplicitCast`: Add explicit cast in Index.cpp - `performance-inefficient-vector-operation`: Add reserve() in IndexBinaryIVF.cpp - `performance-for-range-copy`: Use const reference in IndexBinaryHash.cpp range-for - `facebook-hte-UnassignedReleasedUniquePointer`: Capture release() results in IVFlib.cpp, IndexPreTransform.cpp - `facebook-hte-UnqualifiedCall-sqrt`: Use std::sqrt() in MatrixStats.cpp - `facebook-unused-include-check`: Remove unused includes in IndexIVF.cpp, IndexNNDescent.cpp, IndexNSG.cpp - `clang-diagnostic-switch-enum`: Add missing enum cases in IndexAdditiveQuantizer.cpp, IndexIVFAdditiveQuantizer.cpp Reviewed By: pankajsingh88 Differential Revision: D100592786
1 parent 5bceaf1 commit 10eedbe

File tree

10 files changed

+17
-13
lines changed

10 files changed

+17
-13
lines changed

faiss/AutoTune.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ size_t ParameterSpace::n_combinations() const {
279279

280280
/// get string representation of the combination
281281
std::string ParameterSpace::combination_name(size_t cno) const {
282-
char buf[1000], *wp = buf;
282+
char buf[1000];
283+
char* wp = buf;
283284
*wp = 0;
284285
for (size_t i = 0; i < parameter_ranges.size(); i++) {
285286
FAISS_THROW_IF_NOT_MSG(

faiss/IVFlib.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ IndexIVFResidualQuantizer* ivf_residual_from_quantizer(
492492
faiss::METRIC_L2,
493493
rq.search_type));
494494
index->own_fields = true;
495-
rcq.release();
495+
// Ownership transferred to index via own_fields = true
496+
(void)rcq.release();
496497
index->by_residual = true;
497498
index->rq.initialize_from(rq, nlevel);
498499
index->is_trained = true;

faiss/Index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void Index::add_with_ids(
5555

5656
size_t Index::remove_ids(const IDSelector& /*sel*/) {
5757
FAISS_THROW_MSG("remove_ids not implemented for this type of index");
58-
return -1;
58+
return static_cast<size_t>(-1);
5959
}
6060

6161
void Index::reconstruct(idx_t, float*) const {

faiss/IndexBinaryIVF.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ void search_knn_hamming_count(
526526
idx_t max_codes = params ? params->max_codes : ivf->max_codes;
527527

528528
std::vector<HCounterState<HammingComputer>> cs;
529+
cs.reserve(nx);
529530
for (size_t i = 0; i < nx; ++i) {
530531
cs.push_back(
531532
HCounterState<HammingComputer>(

faiss/IndexIVFAdditiveQuantizer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ InvertedListScanner* IndexIVFAdditiveQuantizer::get_InvertedListScanner(
312312
case AdditiveQuantizer::ST_norm_rq2x4:
313313
A(ST_norm_cqint8)
314314
#undef A
315+
case AdditiveQuantizer::ST_count:
315316
default:
316317
FAISS_THROW_FMT(
317318
"search type %d not supported", aq->search_type);

faiss/IndexNNDescent.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <faiss/impl/AuxIndexStructures.h>
2121
#include <faiss/impl/FaissAssert.h>
2222
#include <faiss/impl/VisitedTable.h>
23-
#include <faiss/utils/distances.h>
2423

2524
extern "C" {
2625

faiss/IndexNSG.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <faiss/impl/AuxIndexStructures.h>
1818
#include <faiss/impl/FaissAssert.h>
1919
#include <faiss/impl/VisitedTable.h>
20-
#include <faiss/utils/distances.h>
2120

2221
namespace faiss {
2322

faiss/IndexPreTransform.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ const float* IndexPreTransform::apply_chain(idx_t n, const float* x) const {
129129
del2.swap(del);
130130
prev_x = xt;
131131
}
132-
del.release();
132+
// Intentionally release ownership: caller takes ownership of the returned
133+
// buffer
134+
(void)del.release();
133135
return prev_x;
134136
}
135137

faiss/MatrixStats.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void MatrixStats::PerDimStats::compute_mean_std() {
5252
if (var < 0) {
5353
var = 0;
5454
}
55-
stddev = sqrt(var);
55+
stddev = std::sqrt(var);
5656
}
5757

5858
void MatrixStats::do_comment(const char* fmt, ...) {
@@ -163,8 +163,8 @@ MatrixStats::MatrixStats(size_t n_in, size_t d_in, const float* x)
163163
}
164164

165165
{ // norm stats
166-
min_norm2 = sqrt(min_norm2);
167-
max_norm2 = sqrt(max_norm2);
166+
min_norm2 = std::sqrt(min_norm2);
167+
max_norm2 = std::sqrt(max_norm2);
168168
do_comment(
169169
"range of L2 norms=[%g, %g] (%zd null vectors)\n",
170170
min_norm2,

faiss/build.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
namespace faiss {
1111

1212
bool has_omp() {
13-
int omp = 1;
13+
int omp_available = 1;
1414
// Detect whether OpenMP is enabled by using the 'max' reduction to render
1515
// the below assignment a no-op. This works:
1616
// 1) without starting any threads
1717
// 2) irrespective of the current thread limit
18-
#pragma omp parallel reduction(max : omp) num_threads(1)
19-
omp = 0;
20-
return omp != 0;
18+
#pragma omp parallel reduction(max : omp_available) num_threads(1)
19+
omp_available = 0;
20+
return omp_available != 0;
2121
}
2222

2323
} // namespace faiss

0 commit comments

Comments
 (0)