Skip to content

Commit

Permalink
Enable modernize-avoid-c-arrays in clang tidy
Browse files Browse the repository at this point in the history
Summary:
changelog: [internal]

In an effort to make our codebase more approachable, I'm enabling more clang-tidy rules.

Read more about modernize-avoid-c-arrays in https://clang.llvm.org/extra/clang-tidy/checks/modernize-avoid-c-arrays.html

Reviewed By: ShikaSD

Differential Revision: D33187162

fbshipit-source-id: c6b3888f67d095274bb492a01132985ae506c0d5
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Dec 20, 2021
1 parent a97e0a8 commit f7c96c0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions ReactCommon/react/renderer/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ InheritParentConfig: true
Checks: '>
clang-diagnostic-*,
modernize-avoid-bind,
modernize-avoid-c-arrays,
'
...
1 change: 1 addition & 0 deletions ReactCommon/react/renderer/core/RawProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "RawProps.h"

#include <react/debug/react_native_assert.h>
#include <react/renderer/core/RawPropsKey.h>
#include <react/renderer/core/RawPropsParser.h>

namespace facebook {
Expand Down
1 change: 0 additions & 1 deletion ReactCommon/react/renderer/core/RawProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <jsi/JSIDynamic.h>
#include <jsi/jsi.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/RawPropsKey.h>
#include <react/renderer/core/RawPropsPrimitives.h>
#include <react/renderer/core/RawValue.h>
#include <vector>
Expand Down
7 changes: 4 additions & 3 deletions ReactCommon/react/renderer/core/RawPropsKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "RawPropsKey.h"

#include <array>
#include <cassert>
#include <cstring>

Expand Down Expand Up @@ -44,11 +45,11 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length)
}

RawPropsKey::operator std::string() const noexcept {
char buffer[kPropNameLengthHardCap];
auto buffer = std::array<char, kPropNameLengthHardCap>();
RawPropsPropNameLength length = 0;
render(buffer, &length);
render(buffer.data(), &length);
react_native_assert(length < kPropNameLengthHardCap);
return std::string{buffer, length};
return std::string{buffer.data(), length};
}

static bool areFieldsEqual(char const *lhs, char const *rhs) {
Expand Down

0 comments on commit f7c96c0

Please sign in to comment.