Instead of casting time_t to uint32_t for the 0xffffffff comparison,
define a TIME_T_MAX and use it for both setting and comparison.

Fixes: c72e245a0e2c ("Add InMon's sFlow Agent library to the build system.")
Signed-off-by: Eelco Chaudron <[email protected]>
--
Note that this checkpatch reports an 'Improper whitespace
around control block' error on this patch. But I did not
want to change the code style in this entire file.
---
 include/openvswitch/types.h  | 3 +++
 lib/sflow_receiver.c         | 3 ++-
 ofproto/ofproto-dpif-sflow.c | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h
index 8c5ec94a6..bfeed752c 100644
--- a/include/openvswitch/types.h
+++ b/include/openvswitch/types.h
@@ -33,6 +33,9 @@ extern "C" {
 #define OVS_FORCE
 #endif
 
+/* Maximum time_t value. */
+#define TIME_T_MAX   (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
+
 /* The ovs_be<N> types indicate that an object is in big-endian, not
  * native-endian, byte order.  They are otherwise equivalent to uint<N>_t. */
 typedef uint16_t OVS_BITWISE ovs_be16;
diff --git a/lib/sflow_receiver.c b/lib/sflow_receiver.c
index 4162518e3..b5b02c060 100644
--- a/lib/sflow_receiver.c
+++ b/lib/sflow_receiver.c
@@ -146,7 +146,8 @@ void sfl_receiver_tick(SFLReceiver *receiver)
     // if there are any samples to send, flush them now
     if(receiver->sampleCollector.numSamples > 0) sendSample(receiver);
     // check the timeout
-    if(receiver->sFlowRcvrTimeout && (u_int32_t)receiver->sFlowRcvrTimeout != 
0xFFFFFFFF) {
+    if(receiver->sFlowRcvrTimeout
+       && receiver->sFlowRcvrTimeout != TIME_T_MAX) {
        // count down one tick and reset if we reach 0
        if(--receiver->sFlowRcvrTimeout == 0) reset(receiver);
     }
diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
index 4a68e9b94..08c16f6f8 100644
--- a/ofproto/ofproto-dpif-sflow.c
+++ b/ofproto/ofproto-dpif-sflow.c
@@ -808,7 +808,7 @@ dpif_sflow_set_options(struct dpif_sflow *ds,
 
     receiver = sfl_agent_addReceiver(ds->sflow_agent);
     sfl_receiver_set_sFlowRcvrOwner(receiver, "Open vSwitch sFlow");
-    sfl_receiver_set_sFlowRcvrTimeout(receiver, 0xffffffff);
+    sfl_receiver_set_sFlowRcvrTimeout(receiver, TIME_T_MAX);
 
     /* Set the sampling_rate down in the datapath. */
     ds->probability = MAX(1, UINT32_MAX / ds->options->sampling_rate);
-- 
2.44.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to