mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
bitcoin#18843: warn on potentially uninitialized reads
This commit is contained in:
parent
49921dbdd8
commit
638fdf25fd
@ -367,6 +367,7 @@ if test "x$enable_werror" = "xyes"; then
|
|||||||
AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]])
|
AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]])
|
||||||
AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]])
|
AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]])
|
||||||
AX_CHECK_COMPILE_FLAG([-Werror=return-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"],,[[$CXXFLAG_WERROR]])
|
AX_CHECK_COMPILE_FLAG([-Werror=return-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"],,[[$CXXFLAG_WERROR]])
|
||||||
|
AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$CXXFLAGS_overridden" = "xno"; then
|
if test "x$CXXFLAGS_overridden" = "xno"; then
|
||||||
@ -381,6 +382,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
|
|||||||
AX_CHECK_COMPILE_FLAG([-Wredundant-decls],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wredundant-decls"],,[[$CXXFLAG_WERROR]])
|
AX_CHECK_COMPILE_FLAG([-Wredundant-decls],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wredundant-decls"],,[[$CXXFLAG_WERROR]])
|
||||||
AX_CHECK_COMPILE_FLAG([-Wunused-variable],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-variable"],,[[$CXXFLAG_WERROR]])
|
AX_CHECK_COMPILE_FLAG([-Wunused-variable],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-variable"],,[[$CXXFLAG_WERROR]])
|
||||||
AX_CHECK_COMPILE_FLAG([-Wdate-time],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"],,[[$CXXFLAG_WERROR]])
|
AX_CHECK_COMPILE_FLAG([-Wdate-time],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"],,[[$CXXFLAG_WERROR]])
|
||||||
|
AX_CHECK_COMPILE_FLAG([-Wconditional-uninitialized],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wconditional-uninitialized"],,[[$CXXFLAG_WERROR]])
|
||||||
|
|
||||||
## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
|
## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
|
||||||
## unknown options if any other warning is produced. Test the -Wfoo case, and
|
## unknown options if any other warning is produced. Test the -Wfoo case, and
|
||||||
|
@ -30,7 +30,7 @@ LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_POSIX
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
leveldb_libleveldb_a_CPPFLAGS = $(AM_CPPFLAGS) $(LEVELDB_CPPFLAGS_INT) $(LEVELDB_CPPFLAGS)
|
leveldb_libleveldb_a_CPPFLAGS = $(AM_CPPFLAGS) $(LEVELDB_CPPFLAGS_INT) $(LEVELDB_CPPFLAGS)
|
||||||
leveldb_libleveldb_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
leveldb_libleveldb_a_CXXFLAGS = $(filter-out -Wconditional-uninitialized -Werror=conditional-uninitialized, $(AM_CXXFLAGS)) $(PIE_FLAGS)
|
||||||
|
|
||||||
leveldb_libleveldb_a_SOURCES=
|
leveldb_libleveldb_a_SOURCES=
|
||||||
leveldb_libleveldb_a_SOURCES += leveldb/port/atomic_pointer.h
|
leveldb_libleveldb_a_SOURCES += leveldb/port/atomic_pointer.h
|
||||||
|
@ -100,7 +100,10 @@ static bool GetHWRand(unsigned char* ent32) {
|
|||||||
// Not all assemblers support the rdrand instruction, write it in hex.
|
// Not all assemblers support the rdrand instruction, write it in hex.
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
for (int iter = 0; iter < 4; ++iter) {
|
for (int iter = 0; iter < 4; ++iter) {
|
||||||
uint32_t r1, r2;
|
// Initialize to 0 to silence a compiler warning that r1 or r2 may be used
|
||||||
|
// uninitialized. Even if rdrand fails (!ok) it will set the output to 0,
|
||||||
|
// but there is no way that the compiler could know that.
|
||||||
|
uint32_t r1 = 0, r2 = 0;
|
||||||
__asm__ volatile (".byte 0x0f, 0xc7, 0xf0;" // rdrand %eax
|
__asm__ volatile (".byte 0x0f, 0xc7, 0xf0;" // rdrand %eax
|
||||||
".byte 0x0f, 0xc7, 0xf2;" // rdrand %edx
|
".byte 0x0f, 0xc7, 0xf2;" // rdrand %edx
|
||||||
"setc %2" :
|
"setc %2" :
|
||||||
@ -110,7 +113,7 @@ static bool GetHWRand(unsigned char* ent32) {
|
|||||||
WriteLE32(ent32 + 8 * iter + 4, r2);
|
WriteLE32(ent32 + 8 * iter + 4, r2);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
uint64_t r1, r2, r3, r4;
|
uint64_t r1 = 0, r2 = 0, r3 = 0, r4 = 0; // See above why we initialize to 0.
|
||||||
__asm__ volatile (".byte 0x48, 0x0f, 0xc7, 0xf0, " // rdrand %rax
|
__asm__ volatile (".byte 0x48, 0x0f, 0xc7, 0xf0, " // rdrand %rax
|
||||||
"0x48, 0x0f, 0xc7, 0xf3, " // rdrand %rbx
|
"0x48, 0x0f, 0xc7, 0xf3, " // rdrand %rbx
|
||||||
"0x48, 0x0f, 0xc7, 0xf1, " // rdrand %rcx
|
"0x48, 0x0f, 0xc7, 0xf1, " // rdrand %rcx
|
||||||
|
Loading…
Reference in New Issue
Block a user