As discussed in GH #2838, the previous fix
f399dbf
("MINOR: stktable: fix potential build issue in smp_to_stkey") which
attempted to remove conversion ambiguity and prevent build warning proved
to be insufficient.
This time, we implement Willy's suggestion, which is to use an union to
perform the conversion.
Hopefully this should fix GH #2838. If that's the case (and only in that
case), then this patch may be backported with
f399dbf (else the patch
won't apply) anywhere
b59d1fd ("BUG/MINOR: stktable: fix big-endian
compatiblity in smp_to_stkey()") was backported.
case SMP_T_SINT:
{
- uint *_sint = (uint *)&smp->data.u.sint;
+ union {
+ uint32_t u32;
+ int64_t s64;
+ } conv;
/* The stick table require a 32bit unsigned int, "sint" is a
* signed 64 it, so we can convert it inplace.
*/
- *_sint = (uint)smp->data.u.sint;
- static_table_key.key = _sint;
+ conv.s64 = 0;
+ conv.u32 = smp->data.u.sint;
+ smp->data.u.sint = conv.s64;
+
+ static_table_key.key = &smp->data.u.sint;
static_table_key.key_len = 4;
break;
}