Closed GoogleCodeExporter closed 9 years ago
Hi,
The signed/unsigned warnings are an unfortunate side effect of Google's C++
coding style, and we disable those internally, so I don't think we can uglify
the code with casts everywhere to that effect. Of course, we also can't put
#ifdef GOOGLE around things just because they cause warnings in Firefox :-)
We can fix the extra semicolons in DECLARE_bool, but those fixes need to be in
snappy-stubs-internal.h (they're a reimplementation of an internal API).
REGISTER_MODULE_INITIALIZER is a similar story, but without an obvious fix; I
can see if I can get that line out of the open-source distribution somehow.
Original comment by se...@google.com
on 20 Dec 2011 at 2:48
The ifdef GOOGLE part is because those static functions are unused in the open
source version, so it seems silly to keep building it.
Original comment by Ms2...@gmail.com
on 20 Dec 2011 at 3:04
Yeah, they are unused in the open source version, in the sense that they're not
used in a default build. They're still intended to be useful for reconstructing
the table, though.
Original comment by se...@google.com
on 20 Dec 2011 at 4:09
In other code that I've opensourced from google (e.g. google-sparsehash,
google-ctemplate), I've rewritten the code to use size_t and other appropriate
unsigned variables, rather than int, even when int is the
google-style-preferred format. (Of course, I carefully audit each change to
make sure the number really can't be negative, and cause any weird promotion
issues!) To my mind, this is one of the places where two style rules conflict
-- use int type, have no warnings -- and while we can resolve the conflict by
adding -Wno-unsgined-compared to the snappy build, I think a better fix is to
just use unsigned types here.
Looking at the actual patch, I think an unsigned type is called for in any case
with htsize, which is doing <<= which is fragile for signed types (inside
google, we'd probably ask that it be an int64), and is safe enough for
kBlockSize, kInputMarginBytes, etc. I do agree that the fix should be to move
appropriate types from signed to unsigned, and not to throw in casts
everywhere. That said, I would also agree it's appropriate to just leave the
code as it is, and maybe suppress the warning in the Makefile.
If you decide to do the latter, here's how I do it, in case that helps:
In configure.ac:
AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
In Makefile.am:
if GCC
AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
endif GCC
Original comment by csilv...@gmail.com
on 20 Dec 2011 at 11:19
I took a shot at fixing most of the warnings by using size_t for lengths etc.
(with the added bonus that maybe we can encode things larger than 2^32 bytes in
one go if someone would be crazy enough).
Unfortunately, the changes make for a performance loss of a few percent in
decompression. I'll need to figure out what's going on, but now I'll be going
on vacation. :-) I'll try to pick it up sometime in January.
Original comment by se...@google.com
on 22 Dec 2011 at 3:08
Fixed in r56.
Original comment by se...@google.com
on 4 Jan 2012 at 1:11
Issue 58 has been merged into this issue.
Original comment by se...@google.com
on 4 Jan 2012 at 4:46
Original issue reported on code.google.com by
Ms2...@gmail.com
on 20 Dec 2011 at 2:42Attachments: