Re: [ovs-dev] [PATCH] byte-order: Fix undefined behavior of BYTES_TO_BE32.

2017-06-13 Thread Ben Pfaff
On Tue, Jun 13, 2017 at 11:34:25AM -0400, Lance Richardson wrote: > > From: "Ben Pfaff" > > To: "Lance Richardson" > > Cc: d...@openvswitch.org > > Sent: Tuesday, 13 June, 2017 11:17:26 AM > > Subject: Re: [PATCH] byte-order: Fix undefined behavior of

Re: [ovs-dev] [PATCH] byte-order: Fix undefined behavior of BYTES_TO_BE32.

2017-06-13 Thread Lance Richardson
> From: "Ben Pfaff" > To: "Lance Richardson" > Cc: d...@openvswitch.org > Sent: Tuesday, 13 June, 2017 11:17:26 AM > Subject: Re: [PATCH] byte-order: Fix undefined behavior of BYTES_TO_BE32. > > On Tue, Jun 13, 2017 at 09:09:44AM -0400, Lance Richardson wrote:

Re: [ovs-dev] [PATCH] byte-order: Fix undefined behavior of BYTES_TO_BE32.

2017-06-13 Thread Ben Pfaff
On Tue, Jun 13, 2017 at 09:09:44AM -0400, Lance Richardson wrote: > > From: "Ben Pfaff" > > To: d...@openvswitch.org > > Cc: "Ben Pfaff" , "Lance Richardson" > > Sent: Tuesday, 13 June, 2017 12:51:14 AM > > Subject: [PATCH] byte-order: Fix

Re: [ovs-dev] [PATCH] byte-order: Fix undefined behavior of BYTES_TO_BE32.

2017-06-13 Thread Lance Richardson
> From: "Ben Pfaff" > To: d...@openvswitch.org > Cc: "Ben Pfaff" , "Lance Richardson" > Sent: Tuesday, 13 June, 2017 12:51:14 AM > Subject: [PATCH] byte-order: Fix undefined behavior of BYTES_TO_BE32. > > A left shift that would produce a result

[ovs-dev] [PATCH] byte-order: Fix undefined behavior of BYTES_TO_BE32.

2017-06-12 Thread Ben Pfaff
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.