Page MenuHomePhabricator

Fix a compiler warning: unused GetDevURandom()
ClosedPublic

Authored by PiRK on Sep 13 2021, 08:05.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCc2bd741169fe: Fix a compiler warning: unused GetDevURandom()
Summary
random.cpp:255:13: error: unused function 'GetDevURandom' [-Werror,-Wunused-function]

Clang 9.0.0, FreeBSD 12.1

Silence by planting a dummy reference to the GetDevURandom symbol
in the places where we don't call the function.

We see the same warnings in our CI logs.

This is a backport of core#17563

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Sep 13 2021, 08:05

What about [[maybe_unused]] ? That would be more elegant.

What about [[maybe_unused]] ? That would be more elegant.

I thought so too, but Greg Maxwell put some doubt in my mind. The only drawback I can think of with [[maybe_unused]] is that there will be no warning if some day the function ends up actually unused (accidentally or by design).

Relevant quotes from the PR discussion:

@vasild wrote:

Once we are on C++17, we can use maybe_unused directly in the code.

@gmaxwell wrote:

Marking that unused would be a great way to hid an actual bug in the future.

@vasild wrote:

Like what?

(No answer to this last one)

use [[maybe_unused]] when defining the function instead of planting dummy references to the function

Ok I actually read the comments. If there is a rationale for the previous approach then let's stick with that, I don't know if there is a plan to remove that function in the future.

revert back to diff id 29897

This revision is now accepted and ready to land.Sep 15 2021, 05:43