Skip to content

Commit

Permalink
Enable -Wextra in C++ builds (#37383)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/yoga#1294

Pull Request resolved: #37383

Add -Wextra to the build, and fixup some more instances of -Wunused-parameter that it sufaces which were not automatically fixable.

Reviewed By: javache

Differential Revision: D45772846

fbshipit-source-id: 29bf71006f63161521fe5869c3a7d8bf7aae9c81
  • Loading branch information
NickGerleman authored and facebook-github-bot committed May 11, 2023
1 parent b38383a commit 99674b3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,73 +424,73 @@ static void jni_YGNodeCopyStyleJNI(
_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
}

#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
static javatype jni_YGNodeStyleGet##name##JNI( \
JNIEnv* env, jobject obj, jlong nativePointer) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
static javatype jni_YGNodeStyleGet##name##JNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
} \
\
static void jni_YGNodeStyleSet##name##JNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, javatype value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
}

#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
static jlong jni_YGNodeStyleGet##name##JNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
return YogaValue::asJavaLong( \
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
} \
\
static void jni_YGNodeStyleSet##name##JNI( \
JNIEnv* env, jobject obj, jlong nativePointer, javatype value) { \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
}

#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
static jlong jni_YGNodeStyleGet##name##JNI( \
JNIEnv* env, jobject obj, jlong nativePointer) { \
return YogaValue::asJavaLong( \
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
} \
\
static void jni_YGNodeStyleSet##name##JNI( \
JNIEnv* env, jobject obj, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
} \
\
static void jni_YGNodeStyleSet##name##PercentJNI( \
JNIEnv* env, jobject obj, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name##Percent( \
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
} \
\
static void jni_YGNodeStyleSet##name##PercentJNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name##Percent( \
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
}

#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
static void jni_YGNodeStyleSet##name##AutoJNI( \
JNIEnv* env, jobject obj, jlong nativePointer) { \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
}

#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
static jlong jni_YGNodeStyleGet##name##JNI( \
JNIEnv* env, jobject obj, jlong nativePointer, jint edge) { \
return YogaValue::asJavaLong(YGNodeStyleGet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
} \
\
static void jni_YGNodeStyleSet##name##JNI( \
JNIEnv* env, \
jobject obj, \
jlong nativePointer, \
jint edge, \
jfloat value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<float>(value)); \
} \
\
static void jni_YGNodeStyleSet##name##PercentJNI( \
JNIEnv* env, \
jobject obj, \
jlong nativePointer, \
jint edge, \
jfloat value) { \
YGNodeStyleSet##name##Percent( \
_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<float>(value)); \
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
static jlong jni_YGNodeStyleGet##name##JNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
return YogaValue::asJavaLong(YGNodeStyleGet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
} \
\
static void jni_YGNodeStyleSet##name##JNI( \
JNIEnv* /*env*/, \
jobject /*obj*/, \
jlong nativePointer, \
jint edge, \
jfloat value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<float>(value)); \
} \
\
static void jni_YGNodeStyleSet##name##PercentJNI( \
JNIEnv* /*env*/, \
jobject /*obj*/, \
jlong nativePointer, \
jint edge, \
jfloat value) { \
YGNodeStyleSet##name##Percent( \
_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<float>(value)); \
}

YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
Expand Down Expand Up @@ -712,12 +712,17 @@ static void jni_YGNodeSetHasBaselineFuncJNI(
->setBaselineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
}

static void jni_YGNodePrintJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
static void jni_YGNodePrintJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer) {
#ifdef DEBUG
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
YGNodePrint(
node,
(YGPrintOptions) (YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
#else
(void) nativePointer;
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ JNIEXPORT JNIEnv* getCurrentEnv() {
}

void logErrorMessageAndDie(const char* message) {
(void) message;
VANILLAJNI_LOG_ERROR(
"VanillaJni",
"Aborting due to error detected in native code: %s",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ static int YGDefaultLog(
#ifdef ANDROID
#include <android/log.h>
static int YGAndroidLog(
const YGConfigRef config,
const YGNodeRef node,
const YGConfigRef /*config*/,
const YGNodeRef /*node*/,
YGLogLevel level,
const char* format,
va_list args) {
Expand Down

0 comments on commit 99674b3

Please sign in to comment.