The following issues were found

caffe2/opt/backend_cutting.cc
1 issues
Syntax Error: AST broken, 'for' doesn't have two operands.
Error

Line: 402

                context.current_group.clear();
  context.find_supported = false;
  std::vector<TransformSubgraph> subs;
  for (std::vector<NodeRef> frontier(
           external_inputs.begin(), external_inputs.end());
       !frontier.empty();
       context.find_supported = !context.find_supported) {
    Explore(frontier, &context);
    if (context.find_supported) {

            

Reported by Cppcheck.

caffe2/operators/utility_ops_test.cc
1 issues
syntax error
Error

Line: 26

                return;
}

TEST(UtilityOpTest, testReshapeWithScalar) {
  Workspace ws;
  OperatorDef def;
  def.set_name("test_reshape");
  def.set_type("Reshape");
  def.add_input("X");

            

Reported by Cppcheck.

caffe2/operators/utility_ops_gpu_test.cc
1 issues
syntax error
Error

Line: 29

                return;
}

TEST(UtilityOpGPUTest, testReshapeWithScalar) {
  if (!HasCudaGPU())
    return;
  Workspace ws;
  OperatorDef def;
  def.set_name("test_reshape");

            

Reported by Cppcheck.

caffe2/operators/string_ops_test.cc
1 issues
syntax error
Error

Line: 42

                Workspace ws_;
};

TEST_F(StringJoinOpTest, testString1DJoin) {
  std::vector<std::string> input = {"a", "xx", "c"};

  auto blob = std::make_unique<Blob>();
  auto* tensor = BlobGetMutableTensor(blob.get(), CPU);
  tensor->Resize(input.size());

            

Reported by Cppcheck.

caffe2/operators/roi_align_rotated_op.cc
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 289 Column: 16 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                        output_vals /= count;

          int index_nhw = index_n + (ph * pooled_width + pw) * channels;
          std::memcpy(
              top_data + index_nhw, output_vals.data(), channels * sizeof(T));
        } // for pw
      } // for ph
    } // if nhwc
  } // for n

            

Reported by FlawFinder.

caffe2/operators/roi_align_op_gpu_test.cc
1 issues
syntax error
Error

Line: 198

              
} // namespace

TEST(RoiAlignTest, CheckCPUGPUEqual) {
  if (!caffe2::HasCudaGPU())
    return;

  Tensor y_cpu(CPU);
  Tensor y_gpu(CPU);

            

Reported by Cppcheck.

caffe2/operators/resize_op.cc
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 152 Column: 14 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                    for (int x = 0; x < output_width; ++x) {
        // NOLINTNEXTLINE(bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions)
        const int in_x = std::min((int)(x / width_scale_), (input_width - 1));
        std::memcpy(
            &Ydata[output_width_stride * y + num_channels * x],
            &Xdata[input_width_stride * in_y + num_channels * in_x],
            num_channels * sizeof(float));
      }
    }

            

Reported by FlawFinder.

caffe2/operators/reshape_op_gpu_test.cc
1 issues
syntax error
Error

Line: 30

                return;
}

TEST(ReshapeOpGPUTest, testReshapeWithScalar) {
  if (!HasCudaGPU())
    return;
  Workspace ws;
  OperatorDef def;
  def.set_name("test_reshape");

            

Reported by Cppcheck.

caffe2/operators/reducer_functors.h
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 778 Column: 7 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                    output_vec =
          output_vec.cwiseMax(ConstEigenVectorMap<T>(in, meta.block_size));
    } else {
      memcpy(out_, in, sizeof(T) * meta.block_size);
    }
    ++current_size_;
  }

 private:

            

Reported by FlawFinder.

caffe2/operators/quantized/int8_test.cc
1 issues
syntax error
Error

Line: 45

              
// LeakyReLU isn't build in xplat, so this fails buck test
// xplat/caffe2:caffe2_testAndroid
TEST(Int8, DISABLED_LeakyReLU) {
  auto XQ = q({1, 224, 224, 3});
  auto X = dq(*XQ);
  const float alpha = 0.1;
  auto xop = CreateOperatorDef(
      "LeakyRelu", "", {"X"}, {"Y"}, {MakeArgument<float>("alpha", alpha)});

            

Reported by Cppcheck.