Repository: google/flatbuffers
File: include/flatbuffers/verifier.h (C/C++)

Code before:
    // Manually implemented constructors for compilers that can't figure it out.
    Options() = default;
    Options(uoffset_t d, uoffset_t t, bool a, bool n)
        : max_depth(d),
          max_tables(t),
          check_alignment(a),
          check_nested_flatbuffers(n) {}
  };

  Verifier(const uint8_t *const buf, const size_t buf_len, const Options opts)
      : buf_(buf),
        size_(buf_len),
        opts_(opts),
        upper_bound_(0),
        depth_(0),
        num_tables_(0),
        flex_reuse_tracker_(nullptr) {
    FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE);
  }

  // Deprecated API, please construct with Verifier::Options.
  Verifier(const uint8_t *const buf, const size_t buf_len,
           const uoffset_t _max_depth = 64,
           const uoffset_t _max_tables = 1000000,
           const bool _check_alignment = true,
           const bool _check_nested_flatbuffers = true)
      : Verifier(buf, buf_len,
                 { _max_depth, _max_tables, _check_alignment,
                   _check_nested_flatbuffers }) {}

  // Central location where any verification failures register.
  bool Check(const bool ok) const {
    // clang-format off
    #ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE
      FLATBUFFERS_ASSERT(ok);
    #endif
    #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
      if (!ok)
        upper_bound_ = 0;
    #endif
    // clang-format on
    return ok;
  }

  // Verify any range within the buffer.
  bool Verify(const size_t elem, const size_t elem_len) const {
    // clang-format off
    #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
      auto upper_bound = elem + elem_len;
      if (upper_bound_ < upper_bound)
        upper_bound_ =  upper_bound;

Review comment (suggestion):
Here i would just not add this option, so leave the signature as is. And just default it to true below. That will force people who want this to use the new API and not just use the deprecated one.

Code after:
    // Manually implemented constructors for compilers that can't figure it out.
    Options() = default;
    Options(uoffset_t d, uoffset_t t, bool a, bool n)
        : max_depth(d),
          max_tables(t),
          check_alignment(a),
          check_nested_flatbuffers(n) {}
  };

  Verifier(const uint8_t *const buf, const size_t buf_len, const Options opts)
      : buf_(buf),
        size_(buf_len),
        opts_(opts),
        upper_bound_(0),
        depth_(0),
        num_tables_(0),
        flex_reuse_tracker_(nullptr) {
    FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE);
  }

  // Deprecated API, please construct with Verifier::Options.
  Verifier(const uint8_t *const buf, const size_t buf_len,
           const uoffset_t _max_depth = 64,
           const uoffset_t _max_tables = 1000000,
           const bool _check_alignment = true)
      : Verifier(buf, buf_len,
                 {
                     _max_depth,
                     _max_tables,
                     _check_alignment,
                     true,
                 }) {}

  // Central location where any verification failures register.
  bool Check(const bool ok) const {
    // clang-format off
    #ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE
      FLATBUFFERS_ASSERT(ok);
    #endif
    #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
      if (!ok)
        upper_bound_ = 0;
    #endif
    // clang-format on
    return ok;
  }

  // Verify any range within the buffer.
  bool Verify(const size_t elem, const size_t elem_len) const {
    // clang-format off
    #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE