Skip to content

Fix miscellaneous lint warnings (#5093)#5093

Open
junjieqi wants to merge 6 commits intomainfrom
export-D100592786
Open

Fix miscellaneous lint warnings (#5093)#5093
junjieqi wants to merge 6 commits intomainfrom
export-D100592786

Conversation

@junjieqi
Copy link
Copy Markdown
Contributor

@junjieqi junjieqi commented Apr 13, 2026

Summary:

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

@meta-cla meta-cla bot added the CLA Signed label Apr 13, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Apr 13, 2026

@junjieqi has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100592786.

junjieqi added a commit that referenced this pull request Apr 13, 2026
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

Differential Revision: D100592786
@meta-codesync meta-codesync bot changed the title Fix miscellaneous lint warnings Fix miscellaneous lint warnings (#5093) Apr 13, 2026
@junjieqi junjieqi force-pushed the export-D100592786 branch from da85635 to 57f5172 Compare April 13, 2026 17:38
junjieqi added a commit that referenced this pull request Apr 13, 2026
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

Differential Revision: D100592786
@junjieqi junjieqi force-pushed the export-D100592786 branch from 57f5172 to 85a80f4 Compare April 13, 2026 17:47
junjieqi added a commit that referenced this pull request Apr 13, 2026
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
@junjieqi junjieqi force-pushed the export-D100592786 branch from 85a80f4 to 10eedbe Compare April 13, 2026 21:00
Junjie Qi added 5 commits April 13, 2026 14:04
Summary:
Fix 59 `cppcoreguidelines-pro-type-member-init` lint warnings by adding `{}` value-initialization to uninitialized member fields across 17 files. This ensures all members are zero/null-initialized by default, preventing potential use of uninitialized values.

Affected files: Index.cpp, Index2Layer.cpp, IndexAdditiveQuantizer.cpp, IndexAdditiveQuantizerFastScan.h, IndexBinaryHash.h, IndexBinaryIVF.cpp, IndexFastScan.h, IndexHNSW.h, IndexIVF.h, IndexIVFAdditiveQuantizer.cpp, IndexIVFFastScan.h, IndexIVFFlat.h, IndexIVFPQ.cpp, IndexIVFPQ.h, IndexPQ.cpp, IndexPQ.h, IndexRowwiseMinMax.cpp.

Differential Revision: D100577736
Summary: Fix 136 `readability-braces-around-statements` lint warnings by adding braces to all single-line `if`, `else`, `for`, and `while` statements across 4 files: `IndexLSH.cpp` (14 issues), `IndexIVFPQ.cpp` (36 issues), `IndexPQ.cpp` (25 issues), and `VectorTransform.cpp` (61 issues). This improves code readability and prevents bugs from accidentally adding statements to unbraced blocks.

Differential Revision: D100580151
Summary:
Fix 172 `clang-diagnostic-shorten-64-to-32` lint warnings across 29 files by adding explicit `static_cast<int>()` or widening variable types where `size_t`/`idx_t` (64-bit) values were implicitly narrowed to `int`/`int32_t` (32-bit).

The fixes fall into two categories:
- **Explicit casts**: Where the receiving API requires `int` and the value is known to fit (e.g., vector dimensions, sub-quantizer counts, cluster counts, BLAS parameters)
- **Type widening**: Where the variable was unnecessarily narrow (e.g., `int nprobe` → `size_t nprobe`, `int list_no` → `size_t list_no`)

Differential Revision: D100588996
…tructors

Summary:
Fix 73 `cppcoreguidelines-special-member-functions` and `clang-diagnostic-deprecated-copy-with-user-provided-dtor` lint warnings across 32 header files by adding explicit `= default` declarations for copy/move constructors and assignment operators to 46 classes that define user-provided destructors.

In C++17+, the implicit generation of copy constructors for classes with user-provided destructors is deprecated. Adding explicit `= default` preserves the existing behavior while satisfying the Rule of Five. Default constructors were also added where needed to maintain existing default-constructibility.

Differential Revision: D100592061
…casts

Summary:
Fix 32 `facebook-avoid-non-const-global-variables` warnings by adding NOLINT comments to intentionally mutable global stats objects and configuration variables that are part of the public API (e.g., `indexIVF_stats`, `hnsw_stats`, `check_compatible_for_merge_expensive_check`). These cannot be made const as they accumulate runtime statistics and provide runtime configuration.

Fix 25 `facebook-security-vulnerable-integer-implicit-cast` warnings by adding explicit `static_cast<size_t>()` to one operand before integer multiplication to prevent overflow before widening. Also fix `clang-diagnostic-switch-enum` warnings by adding missing enum cases to switch statements, and various other minor lint fixes including NOLINT for `-inl.h` includes, `ShadowingClass` fix, and `BadImplicitCast` fix.

Differential Revision: D100592783
junjieqi added a commit that referenced this pull request Apr 13, 2026
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
@junjieqi junjieqi force-pushed the export-D100592786 branch from 10eedbe to 9b98b7c Compare April 13, 2026 21:07
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

std::vector<double> covd(d_in * d_in);
for (size_t i = 0; i < d_in * d_in; i++)
for (size_t i = 0; i < d_in * d_in; i++) {
eig(d_in, covd.data(), eigenvaluesd.data(), verbose);

for (size_t i = 0; i < d_in * d_in; i++)
for (size_t i = 0; i < d_in * d_in; i++) {
@junjieqi junjieqi force-pushed the export-D100592786 branch from 9b98b7c to e23edb8 Compare April 13, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants