HomePhabricator

build: warn on potentially uninitialized reads

Description

build: warn on potentially uninitialized reads

Summary:

Enable -Wconditional-uninitialized to warn on potentially uninitialized reads.

Fix the sole such warning in Bitcoin Core in GetRdRand(): r1 would be
set to 0 on rdrand failure, so initializing it to 0 is a non-functional
change.

From "Intel 64 and IA-32 ArchitecturesSoftware Developer's Manual" [1],
page 1711: "CF=1 indicates that the data in the destination is valid.
Otherwise CF=0 and the data in the destination operand will be returned
as zeros for the specified width."

[1] https://software.intel.com/sites/default/files/managed/39/c5/325462-sdm-vol-1-2abcd-3abcd.pdf

This is a backport of Core PR18843

Test Plan:

cmake .. -GNinja \
    -DCMAKE_C_COMPILER=clang  \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DENABLE_CLANG_TIDY=ON \
    -DCMAKE_C_FLAGS="-Werror"
ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D9110

Details

Provenance
Vasil Dimov <vd@FreeBSD.org>Authored on Thu, Apr 8, 06:45
PiRKCommitted on Thu, Apr 8, 08:29
PiRKPushed on Thu, Apr 8, 08:29
Reviewer
Restricted Project
Differential Revision
D9110: build: warn on potentially uninitialized reads
Parents
rABCb0d8c607a6ca: [secp256k1] initialize variable in tests
Branches
Unknown
Tags
Unknown