BIND 10 #3069: Possible coding error in perfdhcp unit test

BIND 10 Development do-not-reply at isc.org
Thu Jul 25 10:53:33 UTC 2013


#3069: Possible coding error in perfdhcp unit test
-------------------------------------+-------------------------------------
                   Reporter:         |                 Owner:
  stephen                            |                Status:  new
                       Type:         |             Milestone:  DHCP
  defect                             |  Outstanding Tasks
                   Priority:         |              Keywords:
  medium                             |             Sensitive:  0
                  Component:         |           Sub-Project:  DHCP
  perfdhcp                           |  Estimated Difficulty:  0
               CVSS Scoring:         |           Total Hours:  0
            Defect Severity:  N/A    |
Feature Depending on Ticket:         |
        Add Hours to Ticket:  0      |
                  Internal?:  0      |
-------------------------------------+-------------------------------------
 The clang "scan" of the file
 tests/tools/perfdhcp/tests/test_control_unittest.cc gave the following
 warnings:
 {{{
 test_control_unittest.cc:244:50: warning: operator '<<' has lower
 precedence than
 '+'; '+' will be evaluated first [-Wshift-op-parentheses]
     uint16_t opt_i = buf[i + 1] << 8 + buf[i] & 0xFF;
                                             ~~ ~~^~~~~~~~
 test_control_unittest.cc:244:50: note: place parentheses around the '+'
 expression to silence this warning
     uint16_t opt_i = buf[i + 1] << 8 + buf[i] & 0xFF;
                                                  ^
                                                (         )
 test_control_unittest.cc:245:64: warning: operator '<<' has lower
 precedence than
 '+'; '+' will be evaluated first [-Wshift-op-parentheses]
     uint16_t opt_j = requested_options[j + 1] << 8 + requested_options[j]
 & 0xFF;
                                                           ~~
 ~~^~~~~~~~~~~~~~~~~
 test_control_unittest.cc:245:64: note: place parentheses around the '+'
 expression to silence this warning
     uint16_t opt_j = requested_options[j + 1] << 8 + requested_options[j]
 & 0xFF;
                                                                ^
                                                              (
 )
 2 warnings generated.
 }}}
 At first glance, the bracketing of the expressions along the lines of:
 {{{
                 uint16_t opt_i = (buf[i + 1] << 8) + (buf[i] & 0xFF);
 }}}
 seems more logical; however, this should be checked.  At minimum,
 appropriate brackets should be added to silence the warnings.

-- 
Ticket URL: <http://bind10.isc.org/ticket/3069>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list