Skip to content

Conversation

@bneradt
Copy link
Contributor

@bneradt bneradt commented May 14, 2022

This patch addresses the compiler warnings raised by the GCC 11.2.1
compiler on Rocky Linux 8 arm64:

-Werror=shift-negative-value in I_Continuation.h:

In file included from src/ts_asf_master_test_build/iocore/eventsystem/I_Action.h:29,
                 from src/ts_asf_master_test_build/iocore/eventsystem/I_EventSystem.h:32,
                 from src/ts_asf_master_test_build/iocore/eventsystem/I_VConnection.h:29,
                 from QUICStreamVCAdapter.cc:24:
src/ts_asf_master_test_build/iocore/eventsystem/I_Continuation.h: In instantiation of _constexpr int (Continuation::* continuation_handler_void_ptr(int (C::*)(int, T*)))(int, void*) [with C = QUICStreamVCAdapter; T = void; ContinuationHandler = int (Continuation:
:*)(int, void*)]_:
QUICStreamVCAdapter.cc:29:3:   required from here
src/ts_asf_master_test_build/iocore/eventsystem/I_Continuation.h:74:10: error: left shift of negative value [-Werror=shift-negative-value]
   74 |   return static_cast<ContinuationHandler>(fp2);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-Werror=sign-compare in fastlz.cc:

fastlz.cc: In function _void flz_copy64(uint8_t*, const uint8_t*, uint32_t)_:
fastlz.cc:209:17: error: comparison of integer expressions of different signedness: _int_ and _uint32_t_ {aka _unsigned int_} [-Werror=sign-compare]
  209 |   for (c = 0; c < count * 8; ++c) {
      |               ~~^~~~~~~~~~~

-Werror=maybe-uninitialized in header_rewrite:

header_rewrite/conditions.cc: In static member function _static void ConditionInbound::append_value(std::string&, const Resources&, NetworkSessionQualifiers)_:
header_rewrite/conditions.cc:1131:56: error: _tags_ may be used uninitialized [-Werror=maybe-uninitialized]
 1131 |     TSHttpTxnClientProtocolStackGet(res.txnp, tags.size(), tags.data(), &count);
      |                                               ~~~~~~~~~^~
In file included from header_rewrite/conditions.cc:29:
/opt/rh/gcc-toolset-11/root/usr/include/c++/11/array:176:7: note: by argument 1 of type _const std::array<const char*, 8>*_ to _constexpr std::array<_Tp, _Nm>::size_type std::array<_Tp, _Nm>::size() const [with _Tp = const char*; long unsigned int _Nm = 8]_ declared here
  176 |       size() const noexcept { return _Nm; }
      |       ^~~~
header_rewrite/conditions.cc:1128:33: note: _tags_ declared here
 1128 |     std::array<char const *, 8> tags;
      |                                 ^~~~

-Werror=type-limits in traffic_dump:

experimental/traffic_dump/json_utils.cc: In function _int {anonymous}::esc_json_out(const char*, int64_t, std::ostream&)_:
experimental/traffic_dump/json_utils.cc:117:18: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  117 |       if ('\x00' <= c && c <= '\x1f') {
      |           ~~~~~~~^~~~

@bneradt bneradt requested review from randall and ywkaras May 14, 2022 23:16
@bneradt bneradt self-assigned this May 14, 2022
@bneradt bneradt added the Build work related to build configuration or environment label May 14, 2022
@bneradt bneradt added this to the 10.0.0 milestone May 14, 2022
@bneradt bneradt force-pushed the fix_rocky_8_arm64_compiler_warnings branch from d86e8a5 to 213ac02 Compare May 15, 2022 02:02
randall
randall previously approved these changes May 16, 2022
Copy link
Contributor

@ywkaras ywkaras left a comment

Choose a reason for hiding this comment

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

Use of reinterpret_cast may result in a wild this pointer, and it bypasses some compile-time checking.

This patch addresses the compiler warnings raised by the GCC 11.2.1
compiler on Rocky Linux 8 arm64:

-Werror=shift-negative-value in I_Continuation.h:

In file included from src/ts_asf_master_test_build/iocore/eventsystem/I_Action.h:29,
                 from src/ts_asf_master_test_build/iocore/eventsystem/I_EventSystem.h:32,
                 from src/ts_asf_master_test_build/iocore/eventsystem/I_VConnection.h:29,
                 from QUICStreamVCAdapter.cc:24:
src/ts_asf_master_test_build/iocore/eventsystem/I_Continuation.h: In instantiation of _constexpr int (Continuation::* continuation_handler_void_ptr(int (C::*)(int, T*)))(int, void*) [with C = QUICStreamVCAdapter; T = void; ContinuationHandler = int (Continuation:
:*)(int, void*)]_:
QUICStreamVCAdapter.cc:29:3:   required from here
src/ts_asf_master_test_build/iocore/eventsystem/I_Continuation.h:74:10: error: left shift of negative value [-Werror=shift-negative-value]
   74 |   return static_cast<ContinuationHandler>(fp2);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-Werror=sign-compare in fastlz.cc:

This fixes a gcc 11.2.1 compiler warning in Rocky Linux 8 arm64:

fastlz.cc: In function _void flz_copy64(uint8_t*, const uint8_t*, uint32_t)_:
fastlz.cc:209:17: error: comparison of integer expressions of different signedness: _int_ and _uint32_t_ {aka _unsigned int_} [-Werror=sign-compare]
  209 |   for (c = 0; c < count * 8; ++c) {
      |               ~~^~~~~~~~~~~

-Werror=maybe-uninitialized in header_rewrite:

header_rewrite/conditions.cc: In static member function _static void ConditionInbound::append_value(std::string&, const Resources&, NetworkSessionQualifiers)_:
header_rewrite/conditions.cc:1131:56: error: _tags_ may be used uninitialized [-Werror=maybe-uninitialized]
 1131 |     TSHttpTxnClientProtocolStackGet(res.txnp, tags.size(), tags.data(), &count);
      |                                               ~~~~~~~~~^~
In file included from header_rewrite/conditions.cc:29:
/opt/rh/gcc-toolset-11/root/usr/include/c++/11/array:176:7: note: by argument 1 of type _const std::array<const char*, 8>*_ to _constexpr std::array<_Tp, _Nm>::size_type std::array<_Tp, _Nm>::size() const [with _Tp = const char*; long unsigned int _Nm = 8]_ declared here
  176 |       size() const noexcept { return _Nm; }
      |       ^~~~
header_rewrite/conditions.cc:1128:33: note: _tags_ declared here
 1128 |     std::array<char const *, 8> tags;
      |                                 ^~~~

-Werror=type-limits in traffic_dump:

experimental/traffic_dump/json_utils.cc: In function _int {anonymous}::esc_json_out(const char*, int64_t, std::ostream&)_:
experimental/traffic_dump/json_utils.cc:117:18: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  117 |       if ('\x00' <= c && c <= '\x1f') {
      |           ~~~~~~~^~~~
@bneradt bneradt force-pushed the fix_rocky_8_arm64_compiler_warnings branch from 213ac02 to 31f331b Compare May 18, 2022 01:21
@bneradt bneradt merged commit ef917f9 into apache:master May 19, 2022
@bneradt bneradt deleted the fix_rocky_8_arm64_compiler_warnings branch May 19, 2022 17:15
zwoop pushed a commit that referenced this pull request May 25, 2022
This patch addresses the compiler warnings raised by the GCC 11.2.1
compiler on Rocky Linux 8 arm64:

-Werror=shift-negative-value in I_Continuation.h:

In file included from src/ts_asf_master_test_build/iocore/eventsystem/I_Action.h:29,
                 from src/ts_asf_master_test_build/iocore/eventsystem/I_EventSystem.h:32,
                 from src/ts_asf_master_test_build/iocore/eventsystem/I_VConnection.h:29,
                 from QUICStreamVCAdapter.cc:24:
src/ts_asf_master_test_build/iocore/eventsystem/I_Continuation.h: In instantiation of _constexpr int (Continuation::* continuation_handler_void_ptr(int (C::*)(int, T*)))(int, void*) [with C = QUICStreamVCAdapter; T = void; ContinuationHandler = int (Continuation:
:*)(int, void*)]_:
QUICStreamVCAdapter.cc:29:3:   required from here
src/ts_asf_master_test_build/iocore/eventsystem/I_Continuation.h:74:10: error: left shift of negative value [-Werror=shift-negative-value]
   74 |   return static_cast<ContinuationHandler>(fp2);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-Werror=sign-compare in fastlz.cc:

This fixes a gcc 11.2.1 compiler warning in Rocky Linux 8 arm64:

fastlz.cc: In function _void flz_copy64(uint8_t*, const uint8_t*, uint32_t)_:
fastlz.cc:209:17: error: comparison of integer expressions of different signedness: _int_ and _uint32_t_ {aka _unsigned int_} [-Werror=sign-compare]
  209 |   for (c = 0; c < count * 8; ++c) {
      |               ~~^~~~~~~~~~~

-Werror=maybe-uninitialized in header_rewrite:

header_rewrite/conditions.cc: In static member function _static void ConditionInbound::append_value(std::string&, const Resources&, NetworkSessionQualifiers)_:
header_rewrite/conditions.cc:1131:56: error: _tags_ may be used uninitialized [-Werror=maybe-uninitialized]
 1131 |     TSHttpTxnClientProtocolStackGet(res.txnp, tags.size(), tags.data(), &count);
      |                                               ~~~~~~~~~^~
In file included from header_rewrite/conditions.cc:29:
/opt/rh/gcc-toolset-11/root/usr/include/c++/11/array:176:7: note: by argument 1 of type _const std::array<const char*, 8>*_ to _constexpr std::array<_Tp, _Nm>::size_type std::array<_Tp, _Nm>::size() const [with _Tp = const char*; long unsigned int _Nm = 8]_ declared here
  176 |       size() const noexcept { return _Nm; }
      |       ^~~~
header_rewrite/conditions.cc:1128:33: note: _tags_ declared here
 1128 |     std::array<char const *, 8> tags;
      |                                 ^~~~

-Werror=type-limits in traffic_dump:

experimental/traffic_dump/json_utils.cc: In function _int {anonymous}::esc_json_out(const char*, int64_t, std::ostream&)_:
experimental/traffic_dump/json_utils.cc:117:18: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  117 |       if ('\x00' <= c && c <= '\x1f') {
      |           ~~~~~~~^~~~

(cherry picked from commit ef917f9)
@zwoop
Copy link
Contributor

zwoop commented May 25, 2022

Cherry-picked to v9.2.x

@zwoop zwoop modified the milestones: 10.0.0, 9.2.0 May 25, 2022
masaori335 pushed a commit to masaori335/trafficserver that referenced this pull request Feb 21, 2023
* asf/9.2.x:
  Updated ChangeLog
  Restore down nameservers after they come back online (apache#8847)
  Fix Rocky Linux 8 arm64 GCC Compiler Warnings (apache#8850)
  Fix `COMPRESSION_ERROR` on valid HPACK input (apache#8817)
  remap_stats: convert to using TSHttpTxnPristineUrlGet and TSHttpTxnClientReqGet for hostname, remove pre remap continuation (apache#8362)
  Re-introduce import to get man_pages list available for sphinx. Closes apache#8858 (apache#8859)
  Add missing configuration files man pages (apache#8861)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build work related to build configuration or environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants