Enable -Wextra in C++ builds (#1294)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1294 X-link: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a97dbecb49
commit
e53d1ee28a
@@ -30,6 +30,7 @@ Pod::Spec.new do |spec|
|
|||||||
'-fexceptions',
|
'-fexceptions',
|
||||||
'-Wall',
|
'-Wall',
|
||||||
'-Werror',
|
'-Werror',
|
||||||
|
'-Wextra',
|
||||||
'-std=c++14',
|
'-std=c++14',
|
||||||
'-fPIC'
|
'-fPIC'
|
||||||
]
|
]
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#define YGBENCHMARKS(BLOCK) \
|
#define YGBENCHMARKS(BLOCK) \
|
||||||
int main(int argc, char const* argv[]) { \
|
int main(int argc, char const* argv[]) { \
|
||||||
|
(void) argc; \
|
||||||
|
(void) argv; \
|
||||||
clock_t __start; \
|
clock_t __start; \
|
||||||
clock_t __endTimes[NUM_REPETITIONS]; \
|
clock_t __endTimes[NUM_REPETITIONS]; \
|
||||||
{ BLOCK } \
|
{ BLOCK } \
|
||||||
@@ -78,9 +80,10 @@ static YGSize _measure(
|
|||||||
YGMeasureMode widthMode,
|
YGMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
YGMeasureMode heightMode) {
|
YGMeasureMode heightMode) {
|
||||||
|
(void) node;
|
||||||
return (YGSize){
|
return (YGSize){
|
||||||
.width = widthMode == YGMeasureModeUndefined ? 10 : width,
|
.width = widthMode == YGMeasureModeUndefined ? 10 : width,
|
||||||
.height = heightMode == YGMeasureModeUndefined ? 10 : width,
|
.height = heightMode == YGMeasureModeUndefined ? 10 : height,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@ add_compile_options(
|
|||||||
-fexceptions
|
-fexceptions
|
||||||
# Enable warnings and warnings as errors
|
# Enable warnings and warnings as errors
|
||||||
-Wall
|
-Wall
|
||||||
|
-Wextra
|
||||||
-Werror
|
-Werror
|
||||||
# Disable RTTI
|
# Disable RTTI
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
||||||
|
@@ -426,31 +426,31 @@ static void jni_YGNodeCopyStyleJNI(
|
|||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
|
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
|
||||||
static javatype jni_YGNodeStyleGet##name##JNI( \
|
static javatype jni_YGNodeStyleGet##name##JNI( \
|
||||||
JNIEnv* env, jobject obj, jlong nativePointer) { \
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
|
||||||
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
|
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static void jni_YGNodeStyleSet##name##JNI( \
|
static void jni_YGNodeStyleSet##name##JNI( \
|
||||||
JNIEnv* env, jobject obj, jlong nativePointer, javatype value) { \
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, javatype value) { \
|
||||||
YGNodeStyleSet##name( \
|
YGNodeStyleSet##name( \
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
|
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
||||||
static jlong jni_YGNodeStyleGet##name##JNI( \
|
static jlong jni_YGNodeStyleGet##name##JNI( \
|
||||||
JNIEnv* env, jobject obj, jlong nativePointer) { \
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
|
||||||
return YogaValue::asJavaLong( \
|
return YogaValue::asJavaLong( \
|
||||||
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
|
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static void jni_YGNodeStyleSet##name##JNI( \
|
static void jni_YGNodeStyleSet##name##JNI( \
|
||||||
JNIEnv* env, jobject obj, jlong nativePointer, jfloat value) { \
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jfloat value) { \
|
||||||
YGNodeStyleSet##name( \
|
YGNodeStyleSet##name( \
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static void jni_YGNodeStyleSet##name##PercentJNI( \
|
static void jni_YGNodeStyleSet##name##PercentJNI( \
|
||||||
JNIEnv* env, jobject obj, jlong nativePointer, jfloat value) { \
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jfloat value) { \
|
||||||
YGNodeStyleSet##name##Percent( \
|
YGNodeStyleSet##name##Percent( \
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
||||||
}
|
}
|
||||||
@@ -458,20 +458,20 @@ static void jni_YGNodeCopyStyleJNI(
|
|||||||
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
|
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
||||||
static void jni_YGNodeStyleSet##name##AutoJNI( \
|
static void jni_YGNodeStyleSet##name##AutoJNI( \
|
||||||
JNIEnv* env, jobject obj, jlong nativePointer) { \
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
|
||||||
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
||||||
static jlong jni_YGNodeStyleGet##name##JNI( \
|
static jlong jni_YGNodeStyleGet##name##JNI( \
|
||||||
JNIEnv* env, jobject obj, jlong nativePointer, jint edge) { \
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
|
||||||
return YogaValue::asJavaLong(YGNodeStyleGet##name( \
|
return YogaValue::asJavaLong(YGNodeStyleGet##name( \
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
|
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static void jni_YGNodeStyleSet##name##JNI( \
|
static void jni_YGNodeStyleSet##name##JNI( \
|
||||||
JNIEnv* env, \
|
JNIEnv* /*env*/, \
|
||||||
jobject obj, \
|
jobject /*obj*/, \
|
||||||
jlong nativePointer, \
|
jlong nativePointer, \
|
||||||
jint edge, \
|
jint edge, \
|
||||||
jfloat value) { \
|
jfloat value) { \
|
||||||
@@ -482,8 +482,8 @@ static void jni_YGNodeCopyStyleJNI(
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static void jni_YGNodeStyleSet##name##PercentJNI( \
|
static void jni_YGNodeStyleSet##name##PercentJNI( \
|
||||||
JNIEnv* env, \
|
JNIEnv* /*env*/, \
|
||||||
jobject obj, \
|
jobject /*obj*/, \
|
||||||
jlong nativePointer, \
|
jlong nativePointer, \
|
||||||
jint edge, \
|
jint edge, \
|
||||||
jfloat value) { \
|
jfloat value) { \
|
||||||
@@ -712,12 +712,17 @@ static void jni_YGNodeSetHasBaselineFuncJNI(
|
|||||||
->setBaselineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
|
->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
|
#ifdef DEBUG
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||||
YGNodePrint(
|
YGNodePrint(
|
||||||
node,
|
node,
|
||||||
(YGPrintOptions) (YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
|
(YGPrintOptions) (YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
|
||||||
|
#else
|
||||||
|
(void) nativePointer;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,6 +56,7 @@ JNIEXPORT JNIEnv* getCurrentEnv() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void logErrorMessageAndDie(const char* message) {
|
void logErrorMessageAndDie(const char* message) {
|
||||||
|
(void) message;
|
||||||
VANILLAJNI_LOG_ERROR(
|
VANILLAJNI_LOG_ERROR(
|
||||||
"VanillaJni",
|
"VanillaJni",
|
||||||
"Aborting due to error detected in native code: %s",
|
"Aborting due to error detected in native code: %s",
|
||||||
|
@@ -290,7 +290,7 @@ EventArgs createArgs(const YGNode& node, const Event::Data data) {
|
|||||||
using Data = Event::TypedData<E>;
|
using Data = Event::TypedData<E>;
|
||||||
auto deleteData = [](void* x) { delete static_cast<Data*>(x); };
|
auto deleteData = [](void* x) { delete static_cast<Data*>(x); };
|
||||||
|
|
||||||
return {&node, E, {new Data{(data.get<E>())}, deleteData}};
|
return {&node, E, {new Data{(data.get<E>())}, deleteData}, nullptr};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <Event::Type E>
|
template <Event::Type E>
|
||||||
|
@@ -19,9 +19,9 @@ int nodeInstanceCount = 0;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void yogaEventSubscriber(
|
void yogaEventSubscriber(
|
||||||
const YGNode& node,
|
const YGNode& /*node*/,
|
||||||
Event::Type eventType,
|
Event::Type eventType,
|
||||||
const Event::Data& eventData) {
|
const Event::Data& /*eventData*/) {
|
||||||
|
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
case Event::NodeAllocation:
|
case Event::NodeAllocation:
|
||||||
|
@@ -42,8 +42,8 @@ static int YGDefaultLog(
|
|||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
static int YGAndroidLog(
|
static int YGAndroidLog(
|
||||||
const YGConfigRef config,
|
const YGConfigRef /*config*/,
|
||||||
const YGNodeRef node,
|
const YGNodeRef /*node*/,
|
||||||
YGLogLevel level,
|
YGLogLevel level,
|
||||||
const char* format,
|
const char* format,
|
||||||
va_list args) {
|
va_list args) {
|
||||||
|
Reference in New Issue
Block a user