Closed GoogleCodeExporter closed 8 years ago
Thanks for notification Stefan.
Unfortunately, I don't have access to Xcode currently, so can't reproduce the
test independently. But I'll trust your report.
Warning 1 underlines, maybe by chance, that there is a small, harmless, error
in :
ALLOCATOR(sizeof(U64), LZ4_STREAMDECODESIZE_U64)
The arguments should be swapped :
ALLOCATOR(LZ4_STREAMDECODESIZE_U64, sizeof(U64))
because the macro prototype is
ALLOCATOR(n,s) calloc(n,s)
Not sure if it solves the warning, and it doesn't change the amount of reserved
memory either. It just makes it clearer for calloc() that we want the buffer to
be 8-bytes aligned.
If it doesn't solve the warning, maybe it will be necessary to stop using
calloc and use malloc instead.
Warning 2 is more troublesome, because it's a false positive.
The static analyzer cannot know that it's impossible for the function to go
straight from initialization block to dstage_checkSuffix, where the warning
lies.
dstage_checkSuffix is always and only accessed after selectedIn gets properly
initialized,
either at dstage_getSuffix or dstage_storeSuffix.
Maybe I would need to find a way to write the code in a different way, which
would not confuse the static analyzer. Not exactly a top priority item though,
but if it can help making the code clearer, it's still welcomed.
Regards
Original comment by yann.col...@gmail.com
on 11 Mar 2015 at 2:37
@Yann,
Real entity of Xcode's static analyzer is "Clang Static Analyzer" [1].
You can install it to Linux platform easily. But since static analyzer is still
WIP stage, official "LLVM Debian/Ubuntu nightly packages" [2] may be good
source for it.
The following commands are typical installation and analyze procedure.
# Install clang package
sudo apt-get install -y clang-3.5
scan-build-3.5 -v
# Static analysis
cd /path/to/lz4/programs/
make clean
scan-build-3.5 make
See "scan-build: running the analyzer from the command line" [3] for
scan-build's usage.
[1] http://clang-analyzer.llvm.org/
[2] http://llvm.org/apt/
[3] http://clang-analyzer.llvm.org/scan-build.html
Original comment by takayuki...@gmail.com
on 11 Mar 2015 at 6:56
Thanks Takayuki.
I wasn't aware of scan-build.
Indeed, it's possible to reproduce the test now.
Best Regards :)
Original comment by yann.col...@gmail.com
on 11 Mar 2015 at 9:06
Original comment by yann.col...@gmail.com
on 15 Mar 2015 at 12:46
Original comment by yann.col...@gmail.com
on 15 Mar 2015 at 12:46
There's a new version in the dev branch
https://github.com/Cyan4973/lz4/tree/dev
which seems to fix this issue.
They were both false positive.
There was no problem, but the static analyzer couldn't guess it.
I had the feeling that I could use this opportunity to make the code a bit more
explicit.
Which I did. I also extended the use of scan-build to the entire branch.
So hopefully, it doesn't detect any other false positive anymore.
It's a minor improvement, but now it is an automated one.
Hopefully, it should help strengthen reliability of the code for the future.
Original comment by yann.col...@gmail.com
on 15 Mar 2015 at 12:49
Original comment by yann.col...@gmail.com
on 16 Mar 2015 at 11:42
I can confirm that the dev branch solves this problem. Cannot wait for it to be
merged back :)
Question: what should I use as the 'official' source code repository for lz4?
The google code repo, or the github repo?
Original comment by stefan.v...@gmail.com
on 16 Mar 2015 at 8:50
Starting r128 (next version), Github will become the official repo.
Original comment by yann.col...@gmail.com
on 16 Mar 2015 at 8:53
Integrated into r128
Original comment by yann.col...@gmail.com
on 31 Mar 2015 at 1:37
Original issue reported on code.google.com by
stefan.v...@gmail.com
on 11 Mar 2015 at 2:03