[ovs-git] [openvswitch/ovs] 312fc0: extract-ofp-errors: Avoid unintentional sign exten...

GitHub noreply at github.com
Fri Jun 2 04:02:11 UTC 2017


  Branch: refs/heads/branch-2.4
  Home:   https://github.com/openvswitch/ovs
  Commit: 312fc0177ef095caf1e2e36d93ae5857d542ea4a
      https://github.com/openvswitch/ovs/commit/312fc0177ef095caf1e2e36d93ae5857d542ea4a
  Author: Ben Pfaff <blp at ovn.org>
  Date:   2017-06-01 (Thu, 01 Jun 2017)

  Changed paths:
    M build-aux/extract-ofp-errors

  Log Message:
  -----------
  extract-ofp-errors: Avoid unintentional sign extension in generated code.

Code generated by this program includes constructs like this:

    switch (((uint64_t) vendor << 32) | (type << 16) | code)

with variables uint32_t vendor, uint16_t type, uint16_t code.  By C rules,
"type << 16" has type "int", which means that it will be sign-extended to
64 bits when ORed with uint64_t.  Thus, if 'type' has bit 15 set, then
the overall result will have all of its top 32 bits set, which is not
the desired result.

This commit fixes the problem.

No actual error types used in OVS or OpenFlow have bit 15 set, so this
does not fix a user-visible problem.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762955&defectInstanceId=4304798&mergedDefectId=180406
Signed-off-by: Ben Pfaff <blp at ovn.org>
Acked-by: Justin Pettit <jpettit at ovn.org>




More information about the git mailing list