The following issues were found

caffe2/core/plan_executor_test.cc
1 issues
syntax error
Error

Line: 272

                }
};

TEST(PlanExecutorTest, ErrorAsyncPlan) {
  HandleExecutorThreadExceptionsGuard guard;

  cancelCount = 0;
  PlanDef plan_def = parallelErrorPlan();
  Workspace ws;

            

Reported by Cppcheck.

caffe2/core/parallel_net_test.cc
1 issues
syntax error
Error

Line: 110

              }
} // namespace

TEST(DAGNetTest, TestDAGNetTiming) {
  int ms = RunNetAndGetDuration(string(kSleepNetDefString), "dag");
  EXPECT_NEAR(ms, 200, kTimeThreshold);
}

// For sanity check, we also test the sequential time - it should take 0.35

            

Reported by Cppcheck.

caffe2/core/operator_test.cc
1 issues
syntax error
Error

Line: 72

              REGISTER_CUDA_OPERATOR(JustTest, JustTest);
REGISTER_CPU_OPERATOR(JustTestWithSomeOutput, JustTestWithSomeOutput);

TEST(OperatorTest, DeviceTypeRegistryWorks) {
  EXPECT_EQ(gDeviceTypeRegistry()->count(CPU), 1);
}

TEST(OperatorTest, RegistryWorks) {
  OperatorDef op_def;

            

Reported by Cppcheck.

caffe2/core/operator_schema_test.cc
1 issues
syntax error
Error

Line: 16

                .Input(0, "in0", "dummy input.")
  .Output(0, "out0", "dummy output.");

TEST(OperatorSchemaTest, BasicSchema) {
  const OpSchema* schema = OpSchemaRegistry::Schema("OpSchemaTestOp");
#ifdef CAFFE2_NO_OPERATOR_SCHEMA
  EXPECT_TRUE(schema == nullptr);
  return;
#endif

            

Reported by Cppcheck.

caffe2/core/operator_gpu_test.cc
1 issues
syntax error
Error

Line: 46

              REGISTER_CUDA_OPERATOR(JustTest, JustTestCUDA);
REGISTER_CUDNN_OPERATOR(JustTest, JustTestCUDNN);

TEST(EnginePrefTest, GPUDeviceDefaultPreferredEngines) {
  if (!HasCudaGPU())
    return;
  OperatorDef op_def;
  Workspace ws;
  op_def.mutable_device_option()->set_device_type(PROTO_CUDA);

            

Reported by Cppcheck.

caffe2/core/observer_test.cc
1 issues
syntax error
Error

Line: 93

              }
}

TEST(ObserverTest, TestNotify) {
  auto count_before = counter.load();
  Workspace ws;
  ws.CreateBlob("in");
  NetDef net_def;
  unique_ptr<NetBase> net(CreateNetTestHelper(&ws));

            

Reported by Cppcheck.

caffe2/core/nomnigraph/tests/test_util.h
1 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 19 Column: 15 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

              };

struct NNEquality {
  static bool equal(
      const typename nom::repr::NNGraph::NodeRef& a,
      const typename nom::repr::NNGraph::NodeRef& b) {
    if (
        !nom::repr::nn::is<nom::repr::NeuralNetOperator>(a) ||
        !nom::repr::nn::is<nom::repr::NeuralNetOperator>(b)) {

            

Reported by FlawFinder.

caffe2/core/net_test.cc
1 issues
syntax error
Error

Line: 92

              
} // namespace

TEST(NetTest, ConstructionNoDeclaredInputOutput) {
  Workspace ws;
  ws.CreateBlob("in");
  unique_ptr<NetBase> net(
      CreateNetTestHelper(&ws, vector<string>(), vector<string>()));
  EXPECT_TRUE(net.get() != nullptr);

            

Reported by Cppcheck.

caffe2/core/net_simple_refcount_test.cc
1 issues
syntax error
Error

Line: 35

              
OPERATOR_SCHEMA(NetSimpleRefCountTest).NumInputs(1).NumOutputs(1);

TEST(NetSimpleRefCountTest, TestCorrectness) {
  Workspace ws;
  *(ws.CreateBlob("a")->GetMutable<int32_t>()) = 1;
  NetDef net_def;
  net_def.set_type("simple_refcount");
  net_def.add_op()->CopyFrom(

            

Reported by Cppcheck.

caffe2/core/net_gpu_test.cc
1 issues
syntax error
Error

Line: 89

                }
}

TEST(NetTest, DISABLED_ChainingForDifferentDevices) {
  const auto spec = R"DOC(
        name: "example"
        type: "dag"
        external_input: "in"
        op {

            

Reported by Cppcheck.