The following issues were found
test/distributed/elastic/multiprocessing/bin/echo1.py
1 issues
Line: 1
Column: 1
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import argparse
Reported by Pylint.
caffe2/utils/string_utils.h
1 issues
Line: 26
Column: 12
CWE codes:
126
Suggestion:
This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it
const std::string& str,
const std::string& prefix) {
return str.length() >= prefix.length() &&
std::mismatch(prefix.begin(), prefix.end(), str.begin()).first ==
prefix.end();
}
TORCH_API inline bool EndsWith(
const std::string& full,
Reported by FlawFinder.
caffe2/utils/smart_tensor_printer_test.cc
1 issues
Line: 44
#if !(__APPLE__) // TODO(janusz): thread_local does not work under mac.
TEST(SmartTensorPrinterTest, SimpleTest) {
printTensorAndCheck(std::vector<int>{1, 2, 3, 4, 5});
printTensorAndCheck(std::vector<std::string>{"bob", "alice", "facebook"});
}
#endif // !(__APPLE__)
Reported by Cppcheck.
caffe2/utils/simple_queue_test.cc
1 issues
Line: 27
}
TEST(SimpleQueueTest, SingleProducerSingleConsumer) {
// NOLINTNEXTLINE(modernize-make-unique)
gQueue.reset(new SimpleQueue<int>());
std::thread consumer(ConsumerFunction, 0);
for (int i = 0; i < 10; ++i) {
gQueue->Push(i);
Reported by Cppcheck.
test/cpp/jit/test_irparser.cpp
1 issues
Line: 42
AT_ASSERT(original == parsed);
}
TEST(IRParserTest, Basic) {
auto graph = std::make_shared<Graph>();
std::unordered_map<std::string, Value*> vmap;
parseIR(
R"IR(
graph(%0 : Tensor, %1 : Tensor):
Reported by Cppcheck.
caffe2/utils/math_test.cc
1 issues
Line: 93
}
}
TEST(MathTest, GemmNoTransTrans) {
DeviceOption option;
CPUContext cpu_context(option);
Tensor X(std::vector<int>{5, 10}, CPU);
Tensor W(std::vector<int>{6, 10}, CPU);
Tensor Y(std::vector<int>{5, 6}, CPU);
Reported by Cppcheck.
caffe2/utils/math_gpu_test.cc
1 issues
Line: 82
}
}
TEST(MathUtilGPUTest, testAddStripedBatch) {
if (!HasCudaGPU())
return;
Workspace ws;
DeviceOption option;
option.set_device_type(PROTO_CUDA);
Reported by Cppcheck.
scripts/get_python_cmake_flags.py
1 issues
Line: 1
Column: 1
## @package get_python_cmake_flags
# Module scripts.get_python_cmake_flags
##############################################################################
# Use this script to find your preferred python installation.
##############################################################################
#
# You can use the following to build with your preferred version of python
# if your installation is not being properly detected by CMake.
#
Reported by Pylint.
test/cpp_extensions/rng_extension.cpp
1 issues
Line: 20
Column: 12
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
~TestCPUGenerator() {
--instance_count;
}
uint32_t random() { return static_cast<uint32_t>(value_); }
uint64_t random64() { return value_; }
void set_current_seed(uint64_t seed) override { throw std::runtime_error("not implemented"); }
uint64_t current_seed() const override { throw std::runtime_error("not implemented"); }
uint64_t seed() override { throw std::runtime_error("not implemented"); }
void set_state(const c10::TensorImpl& new_state) override { throw std::runtime_error("not implemented"); }
Reported by FlawFinder.
caffe2/utils/hip/math_blas_gpu_test.cc
1 issues
Line: 110
}
}
TEST(MathROCBLASTest, GemmNoTransTrans) {
if (!HasHipGPU())
return;
Workspace ws;
DeviceOption option;
option.set_device_type(PROTO_HIP);
Reported by Cppcheck.