Skip to content

Conversation

@apoelstra
Copy link
Contributor

Yesterday LLVM 3.2 was released, as well as a corresponding version of the clang compiler and static analyzer.

I ran the static analyzer over the bitcoin code and picked up a couple of assignments to variables that are never read. These two patches remove those assigments.

@BitcoinPullTester
Copy link

src/serialize.h Outdated
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs 4 spaced as indention :).

@BitcoinPullTester
Copy link

@Diapolo
Copy link

Diapolo commented Dec 26, 2012

I'm interested in how that analyzer outputs found stuff, can you perhaps post that? As I'm on Windows it's not that easy to get such stuff working over here ;).

@apoelstra
Copy link
Contributor Author

On Linux, you can get the analyzer to run by adding

CXX=clang++ --analyze

right above the "LINK=$(CXX)" line in makefile.unix, then do a full build. It will output its warnings as though it were a compiler (though it won't actually compile anything). I'm not familiar with the Windows build process, sorry.

@laanwj
Copy link
Member

laanwj commented Jan 5, 2013

I've also seen these warnings by the analyzer, but I'm not so sure about removing the code. It's there to make maintenance easier (ie, will make it somewhat more robust when adding code by making sure hSOCKET will never have an invalid value, and nSize will always be up to date). Compilers are generally smart enough to remove dead code like this in the binary.

@sipa
Copy link
Member

sipa commented Jan 6, 2013

agree with @laanwj

Being able to get useful information through a static analyzer is nice, though.

@Diapolo
Copy link

Diapolo commented Jan 6, 2013

It would be indeed better to keep these 2 and so I'm fine with just closing this.

@gavinandresen
Copy link
Contributor

Closing this, I like the belt-and-suspenders easier-to-maintain code.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants