]> granicus.if.org Git - python/commitdiff
Avoid UB in test selection macro. (#3407)
authorDevin Jeanpierre <jeanpierreda@gmail.com>
Thu, 7 Sep 2017 01:00:47 +0000 (18:00 -0700)
committerGregory P. Smith <greg@krypto.org>
Thu, 7 Sep 2017 01:00:47 +0000 (18:00 -0700)
This fixes the gcc "warning: this use of "defined" may not be portable [-Wexpansion-to-defined]"

See discussion in http://bugs.python.org/issue29505

Modules/_xxtestfuzz/fuzzer.c

index 36f721ee62616431f78244ba73b63587624ac37a..b50eb651271043bb48b833de4de1d770ef9fdb0f 100644 (file)
@@ -105,16 +105,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
 
     int rv = 0;
 
-#define _Py_FUZZ_YES(test_name) (defined(_Py_FUZZ_##test_name) || !defined(_Py_FUZZ_ONE))
-#if _Py_FUZZ_YES(fuzz_builtin_float)
+#if !defined(_Py_FUZZ_ONE) || defined(_Py_FUZZ_fuzz_builtin_float)
     rv |= _run_fuzz(data, size, fuzz_builtin_float);
 #endif
-#if _Py_FUZZ_YES(fuzz_builtin_int)
+#if !defined(_Py_FUZZ_ONE) || defined(_Py_FUZZ_fuzz_builtin_int)
     rv |= _run_fuzz(data, size, fuzz_builtin_int);
 #endif
-#if _Py_FUZZ_YES(fuzz_builtin_unicode)
+#if !defined(_Py_FUZZ_ONE) || defined(_Py_FUZZ_fuzz_builtin_unicode)
     rv |= _run_fuzz(data, size, fuzz_builtin_unicode);
 #endif
-#undef _Py_FUZZ_YES
   return rv;
 }