diff options
author | brian-peloton <brian@peloton-tech.com> | 2017-05-23 16:22:57 -0700 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2017-05-23 16:22:57 -0700 |
commit | 40da1ed572d60e9c7cc2fe1ca4175e30682f5a9d (patch) | |
tree | 78c05eefc2a870be1ed053fe77d7f349f4cf1413 /src/google/protobuf/util | |
parent | ba987a7e2d039107d304aa945fee662399461d58 (diff) | |
download | protobuf-40da1ed572d60e9c7cc2fe1ca4175e30682f5a9d.tar.gz protobuf-40da1ed572d60e9c7cc2fe1ca4175e30682f5a9d.tar.bz2 protobuf-40da1ed572d60e9c7cc2fe1ca4175e30682f5a9d.zip |
Removing undefined behavior and compiler warnings (#1315)
* Comment out unused arguments.
These last few are all that's needed to compile with -Wunused-arguments.
* Fix missing struct field initializer.
With this fix, everything compiles with -Wmissing-field-initializers.
* Add support for disabling unaligned memory accesses on x86 too.
ubsan doesn't like these because they are technically undefined
behavior, so -DGOOGLE_PROTOBUF_DONT_USE_UNALIGNED will disable them easily.
* Avoid undefined integer overflow.
ubsan catches all of these.
Diffstat (limited to 'src/google/protobuf/util')
-rw-r--r-- | src/google/protobuf/util/message_differencer.h | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index d99223cb..192266b6 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -241,18 +241,18 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // mutually exclusive. If a field has been both moved and modified, then // only ReportModified will be called. virtual void ReportMoved( - const Message& message1, - const Message& message2, - const std::vector<SpecificField>& field_path) { } + const Message& /* message1 */, + const Message& /* message2 */, + const std::vector<SpecificField>& /* field_path */) { } // Reports that two fields match. Useful for doing side-by-side diffs. // This function is mutually exclusive with ReportModified and ReportMoved. // Note that you must call set_report_matches(true) before calling Compare // to make use of this function. virtual void ReportMatched( - const Message& message1, - const Message& message2, - const std::vector<SpecificField>& field_path) { } + const Message& /* message1 */, + const Message& /* message2 */, + const std::vector<SpecificField>& /* field_path */) { } // Reports that two fields would have been compared, but the // comparison has been skipped because the field was marked as @@ -274,16 +274,16 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // the fields are equal or not (perhaps with a second call to // Compare()), if it cares. virtual void ReportIgnored( - const Message& message1, - const Message& message2, - const std::vector<SpecificField>& field_path) { } + const Message& /* message1 */, + const Message& /* message2 */, + const std::vector<SpecificField>& /* field_path */) { } // Report that an unknown field is ignored. (see comment above). // Note this is a different function since the last SpecificField in field // path has a null field. This could break existing Reporter. virtual void ReportUnknownFieldIgnored( - const Message& message1, const Message& message2, - const std::vector<SpecificField>& field_path) {} + const Message& /* message1 */, const Message& /* message2 */, + const std::vector<SpecificField>& /* field_path */) {} private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reporter); @@ -297,9 +297,9 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { virtual ~MapKeyComparator(); virtual bool IsMatch( - const Message& message1, - const Message& message2, - const std::vector<SpecificField>& parent_fields) const { + const Message& /* message1 */, + const Message& /* message2 */, + const std::vector<SpecificField>& /* parent_fields */) const { GOOGLE_CHECK(false) << "IsMatch() is not implemented."; return false; } @@ -321,18 +321,18 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { // Returns true if the field should be ignored. virtual bool IsIgnored( - const Message& message1, - const Message& message2, - const FieldDescriptor* field, - const std::vector<SpecificField>& parent_fields) = 0; + const Message& /* message1 */, + const Message& /* message2 */, + const FieldDescriptor* /* field */, + const std::vector<SpecificField>& /* parent_fields */) = 0; // Returns true if the unknown field should be ignored. // Note: This will be called for unknown fields as well in which case // field.field will be null. virtual bool IsUnknownFieldIgnored( - const Message& message1, const Message& message2, - const SpecificField& field, - const std::vector<SpecificField>& parent_fields) { + const Message& /* message1 */, const Message& /* message2 */, + const SpecificField& /* field */, + const std::vector<SpecificField>& /* parent_fields */) { return false; } }; |