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',
|
||||
'-Wall',
|
||||
'-Werror',
|
||||
'-Wextra',
|
||||
'-std=c++14',
|
||||
'-fPIC'
|
||||
]
|
||||
|
@@ -17,6 +17,8 @@
|
||||
|
||||
#define YGBENCHMARKS(BLOCK) \
|
||||
int main(int argc, char const* argv[]) { \
|
||||
(void) argc; \
|
||||
(void) argv; \
|
||||
clock_t __start; \
|
||||
clock_t __endTimes[NUM_REPETITIONS]; \
|
||||
{ BLOCK } \
|
||||
@@ -78,9 +80,10 @@ static YGSize _measure(
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGMeasureMode heightMode) {
|
||||
(void) node;
|
||||
return (YGSize){
|
||||
.width = widthMode == YGMeasureModeUndefined ? 10 : width,
|
||||
.height = heightMode == YGMeasureModeUndefined ? 10 : width,
|
||||
.height = heightMode == YGMeasureModeUndefined ? 10 : height,
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,7 @@ add_compile_options(
|
||||
-fexceptions
|
||||
# Enable warnings and warnings as errors
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
# Disable RTTI
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
||||
|
@@ -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);
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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",
|
||||
|
@@ -290,7 +290,7 @@ EventArgs createArgs(const YGNode& node, const Event::Data data) {
|
||||
using Data = Event::TypedData<E>;
|
||||
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>
|
||||
|
@@ -19,9 +19,9 @@ int nodeInstanceCount = 0;
|
||||
namespace {
|
||||
|
||||
void yogaEventSubscriber(
|
||||
const YGNode& node,
|
||||
const YGNode& /*node*/,
|
||||
Event::Type eventType,
|
||||
const Event::Data& eventData) {
|
||||
const Event::Data& /*eventData*/) {
|
||||
|
||||
switch (eventType) {
|
||||
case Event::NodeAllocation:
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user