Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
1b3796c8
Commit
1b3796c8
authored
Jul 23, 2016
by
Feng Xiao
Committed by
GitHub
Jul 23, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1829 from xfxyjwf/fixcpp
Fix sign-comparison warnings and add a test for that.
parents
4ddaad4f
9009662b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
12 deletions
+34
-12
Makefile.am
src/Makefile.am
+28
-6
map.h
src/google/protobuf/map.h
+1
-1
repeated_field_reflection.h
src/google/protobuf/repeated_field_reflection.h
+0
-0
wire_format_lite_inl.h
src/google/protobuf/wire_format_lite_inl.h
+5
-5
No files found.
src/Makefile.am
View file @
1b3796c8
...
@@ -19,8 +19,9 @@ PTHREAD_DEF =
...
@@ -19,8 +19,9 @@ PTHREAD_DEF =
endif
endif
if
GCC
if
GCC
# These are good warnings to turn on by default
# Turn on all warnings except for sign comparison (we ignore sign comparison
NO_OPT_CXXFLAGS
=
$(PTHREAD_CFLAGS)
$(PTHREAD_DEF)
$(ZLIB_DEF)
-Wall
-Wwrite-strings
-Woverloaded-virtual
-Wno-sign-compare
# in Google so our code base have tons of such warnings).
NO_OPT_CXXFLAGS
=
$(PTHREAD_CFLAGS)
$(PTHREAD_DEF)
$(ZLIB_DEF)
-Wall
-Wno-sign-compare
else
else
NO_OPT_CXXFLAGS
=
$(PTHREAD_CFLAGS)
$(PTHREAD_DEF)
$(ZLIB_DEF)
NO_OPT_CXXFLAGS
=
$(PTHREAD_CFLAGS)
$(PTHREAD_DEF)
$(ZLIB_DEF)
endif
endif
...
@@ -50,7 +51,8 @@ clean-local:
...
@@ -50,7 +51,8 @@ clean-local:
rm
-f
*
.loT
rm
-f
*
.loT
CLEANFILES
=
$(protoc_outputs)
unittest_proto_middleman
\
CLEANFILES
=
$(protoc_outputs)
unittest_proto_middleman
\
testzip.jar testzip.list testzip.proto testzip.zip
testzip.jar testzip.list testzip.proto testzip.zip
\
no_warning_test.cc
MAINTAINERCLEANFILES
=
\
MAINTAINERCLEANFILES
=
\
Makefile.in
Makefile.in
...
@@ -122,7 +124,6 @@ nobase_include_HEADERS = \
...
@@ -122,7 +124,6 @@ nobase_include_HEADERS = \
google/protobuf/reflection.h
\
google/protobuf/reflection.h
\
google/protobuf/reflection_ops.h
\
google/protobuf/reflection_ops.h
\
google/protobuf/repeated_field.h
\
google/protobuf/repeated_field.h
\
google/protobuf/repeated_field_reflection.h
\
google/protobuf/service.h
\
google/protobuf/service.h
\
google/protobuf/source_context.pb.h
\
google/protobuf/source_context.pb.h
\
google/protobuf/struct.pb.h
\
google/protobuf/struct.pb.h
\
...
@@ -680,7 +681,7 @@ COMMON_TEST_SOURCES = \
...
@@ -680,7 +681,7 @@ COMMON_TEST_SOURCES = \
check_PROGRAMS
=
protoc protobuf-test protobuf-lazy-descriptor-test
\
check_PROGRAMS
=
protoc protobuf-test protobuf-lazy-descriptor-test
\
protobuf-lite-test test_plugin protobuf-lite-arena-test
\
protobuf-lite-test test_plugin protobuf-lite-arena-test
\
$(GZCHECKPROGRAMS)
no-warning-test
$(GZCHECKPROGRAMS)
protobuf_test_LDADD
=
$(PTHREAD_LIBS)
libprotobuf.la libprotoc.la
\
protobuf_test_LDADD
=
$(PTHREAD_LIBS)
libprotobuf.la libprotoc.la
\
../gmock/gtest/lib/libgtest.la
\
../gmock/gtest/lib/libgtest.la
\
../gmock/lib/libgmock.la
\
../gmock/lib/libgmock.la
\
...
@@ -833,6 +834,27 @@ zcgunzip_LDADD = $(PTHREAD_LIBS) libprotobuf.la
...
@@ -833,6 +834,27 @@ zcgunzip_LDADD = $(PTHREAD_LIBS) libprotobuf.la
zcgunzip_SOURCES
=
google/protobuf/testing/zcgunzip.cc
zcgunzip_SOURCES
=
google/protobuf/testing/zcgunzip.cc
endif
endif
# This test target is to ensure all our public header files and generated
# code is free from warnings. We have to be more pedantic about these
# files because they are compiled by users with different compiler flags.
no_warning_test.cc
:
echo
"// Generated from Makefile.am"
>
no_warning_test.cc
for
FILE
in
$(nobase_include_HEADERS)
;
do
\
if
!
echo
$$
{
FILE
}
|
grep
"atomicops"
;
then
\
echo
"#include <
$$
{FILE}>"
>>
no_warning_test.cc
;
\
fi
\
done
echo
"#include <gtest/gtest.h>"
>>
no_warning_test.cc
echo
"TEST(NoWarningTest, Empty) {}"
>>
no_warning_test.cc
no_warning_test_LDADD
=
$(PTHREAD_LIBS)
libprotobuf.la
\
../gmock/gtest/lib/libgtest.la
\
../gmock/gtest/lib/libgtest_main.la
no_warning_test_CPPFLAGS
=
-I
$(srcdir)
/../gmock/gtest/include
no_warning_test_CXXFLAGS
=
$(PTHREAD_CFLAGS)
$(PTHREAD_DEF)
$(ZLIB_DEF)
\
-Wall
-Werror
nodist_no_warning_test_SOURCES
=
no_warning_test.cc
$(protoc_outputs)
TESTS
=
protobuf-test protobuf-lazy-descriptor-test protobuf-lite-test
\
TESTS
=
protobuf-test protobuf-lazy-descriptor-test protobuf-lite-test
\
google/protobuf/compiler/zip_output_unittest.sh
$(GZTESTS)
\
google/protobuf/compiler/zip_output_unittest.sh
$(GZTESTS)
\
protobuf-lite-arena-test
protobuf-lite-arena-test
no-warning-test
src/google/protobuf/map.h
View file @
1b3796c8
...
@@ -1250,7 +1250,7 @@ class Map {
...
@@ -1250,7 +1250,7 @@ class Map {
// Return whether table_[b] is a linked list that seems awfully long.
// Return whether table_[b] is a linked list that seems awfully long.
// Requires table_[b] to point to a non-empty linked list.
// Requires table_[b] to point to a non-empty linked list.
bool
TableEntryIsTooLong
(
size_type
b
)
{
bool
TableEntryIsTooLong
(
size_type
b
)
{
const
int
kMaxLength
=
8
;
const
size_type
kMaxLength
=
8
;
size_type
count
=
0
;
size_type
count
=
0
;
Node
*
node
=
static_cast
<
Node
*>
(
table_
[
b
]);
Node
*
node
=
static_cast
<
Node
*>
(
table_
[
b
]);
do
{
do
{
...
...
src/google/protobuf/repeated_field_reflection.h
deleted
100644 → 0
View file @
4ddaad4f
This diff is collapsed.
Click to expand it.
src/google/protobuf/wire_format_lite_inl.h
View file @
1b3796c8
...
@@ -346,9 +346,9 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive(
...
@@ -346,9 +346,9 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive(
io
::
CodedInputStream
*
input
,
RepeatedField
<
CType
>*
values
)
{
io
::
CodedInputStream
*
input
,
RepeatedField
<
CType
>*
values
)
{
int
length
;
int
length
;
if
(
!
input
->
ReadVarintSizeAsInt
(
&
length
))
return
false
;
if
(
!
input
->
ReadVarintSizeAsInt
(
&
length
))
return
false
;
const
uint32
old_entries
=
values
->
size
();
const
int
old_entries
=
values
->
size
();
const
uint32
new_entries
=
length
/
sizeof
(
CType
);
const
int
new_entries
=
length
/
sizeof
(
CType
);
const
uint32
new_bytes
=
new_entries
*
sizeof
(
CType
);
const
int
new_bytes
=
new_entries
*
sizeof
(
CType
);
if
(
new_bytes
!=
length
)
return
false
;
if
(
new_bytes
!=
length
)
return
false
;
// We would *like* to pre-allocate the buffer to write into (for
// We would *like* to pre-allocate the buffer to write into (for
// speed), but *must* avoid performing a very large allocation due
// speed), but *must* avoid performing a very large allocation due
...
@@ -382,7 +382,7 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive(
...
@@ -382,7 +382,7 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive(
#else
#else
values
->
Reserve
(
old_entries
+
new_entries
);
values
->
Reserve
(
old_entries
+
new_entries
);
CType
value
;
CType
value
;
for
(
uint32
i
=
0
;
i
<
new_entries
;
++
i
)
{
for
(
int
i
=
0
;
i
<
new_entries
;
++
i
)
{
if
(
!
ReadPrimitive
<
CType
,
DeclaredType
>
(
input
,
&
value
))
return
false
;
if
(
!
ReadPrimitive
<
CType
,
DeclaredType
>
(
input
,
&
value
))
return
false
;
values
->
AddAlreadyReserved
(
value
);
values
->
AddAlreadyReserved
(
value
);
}
}
...
@@ -392,7 +392,7 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive(
...
@@ -392,7 +392,7 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive(
// safely allocate. We read as much as we can into *values
// safely allocate. We read as much as we can into *values
// without pre-allocating "length" bytes.
// without pre-allocating "length" bytes.
CType
value
;
CType
value
;
for
(
uint32
i
=
0
;
i
<
new_entries
;
++
i
)
{
for
(
int
i
=
0
;
i
<
new_entries
;
++
i
)
{
if
(
!
ReadPrimitive
<
CType
,
DeclaredType
>
(
input
,
&
value
))
return
false
;
if
(
!
ReadPrimitive
<
CType
,
DeclaredType
>
(
input
,
&
value
))
return
false
;
values
->
Add
(
value
);
values
->
Add
(
value
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment