[ovs-git] [openvswitch/ovs] a13784: byte-order: Fix undefined behavior of BYTES_TO_BE3...

GitHub noreply at github.com
Tue Jun 13 15:17:04 UTC 2017

  Branch: refs/heads/master
  Home:   https://github.com/openvswitch/ovs
  Commit: a13784ba95efeb5a1f77253df40d433a1ce60087
  Author: Ben Pfaff <blp at ovn.org>
  Date:   2017-06-13 (Tue, 13 Jun 2017)

  Changed paths:
    M lib/byte-order.h
    M lib/flow.c

  Log Message:
  byte-order: Fix undefined behavior of BYTES_TO_BE32.

A left shift that would produce a result that is not representable
by the type of the expression's result has "undefined behavior"
according to the C language standard. Avoid this by casting values
that could set the upper bit to unsigned types.

Also document and convert a macro to a function.

While we're at it, delete the unused macro BE16S_TO_BE32.

Found via gcc's undefined behavior sanitizer.

Reported-by: Lance Richardson <lrichard at redhat.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>
Acked-by: Lance Richardson <lrichard at redhat.com>

More information about the git mailing list