Changed sFlowRcvrTimeout to a uint32_t to avoid time_t warnings
reported by Coverity. A uint32_t is more than large enough as
this is a (seconds) tick counter and OVS is not even using this.
Fixes: c72e245a0e2c ("Add InMon's sFlow Agent library to the build system.")
Signed-off-by: Eelco Chaudron
--
Note that this checkpatch reports an 'Improper whitespace
around control block' error on this patch + some warnings.
But I did not want to change the code style in this entire file.
---
lib/sflow_api.h | 6 +++---
lib/sflow_receiver.c | 7 ---
ofproto/ofproto-dpif-sflow.c | 2 +-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/lib/sflow_api.h b/lib/sflow_api.h
index f4bfa5ead..b884a6a7d 100644
--- a/lib/sflow_api.h
+++ b/lib/sflow_api.h
@@ -97,7 +97,7 @@ typedef struct _SFLReceiver {
struct _SFLReceiver *nxt;
/* MIB fields */
char *sFlowRcvrOwner;
-time_t sFlowRcvrTimeout;
+u_int32_t sFlowRcvrTimeout;
u_int32_t sFlowRcvrMaximumDatagramSize;
SFLAddress sFlowRcvrAddress;
u_int32_t sFlowRcvrPort;
@@ -251,8 +251,8 @@ SFLSampler *sfl_agent_getSamplerByIfIndex(SFLAgent *agent,
u_int32_t ifIndex);
/* receiver */
char * sfl_receiver_get_sFlowRcvrOwner(SFLReceiver *receiver);
voidsfl_receiver_set_sFlowRcvrOwner(SFLReceiver *receiver, char
*sFlowRcvrOwner);
-time_t sfl_receiver_get_sFlowRcvrTimeout(SFLReceiver *receiver);
-voidsfl_receiver_set_sFlowRcvrTimeout(SFLReceiver *receiver, time_t
sFlowRcvrTimeout);
+u_int32_t sfl_receiver_get_sFlowRcvrTimeout(SFLReceiver *receiver);
+voidsfl_receiver_set_sFlowRcvrTimeout(SFLReceiver *receiver, u_int32_t
sFlowRcvrTimeout);
u_int32_t sfl_receiver_get_sFlowRcvrMaximumDatagramSize(SFLReceiver
*receiver);
voidsfl_receiver_set_sFlowRcvrMaximumDatagramSize(SFLReceiver
*receiver, u_int32_t sFlowRcvrMaximumDatagramSize);
SFLAddress *sfl_receiver_get_sFlowRcvrAddress(SFLReceiver *receiver);
diff --git a/lib/sflow_receiver.c b/lib/sflow_receiver.c
index 4162518e3..3c5aec897 100644
--- a/lib/sflow_receiver.c
+++ b/lib/sflow_receiver.c
@@ -102,10 +102,10 @@ void sfl_receiver_set_sFlowRcvrOwner(SFLReceiver
*receiver, char *sFlowRcvrOwner
reset(receiver);
}
}
-time_t sfl_receiver_get_sFlowRcvrTimeout(SFLReceiver *receiver) {
+u_int32_t sfl_receiver_get_sFlowRcvrTimeout(SFLReceiver *receiver) {
return receiver->sFlowRcvrTimeout;
}
-void sfl_receiver_set_sFlowRcvrTimeout(SFLReceiver *receiver, time_t
sFlowRcvrTimeout) {
+void sfl_receiver_set_sFlowRcvrTimeout(SFLReceiver *receiver, u_int32_t
sFlowRcvrTimeout) {
receiver->sFlowRcvrTimeout =sFlowRcvrTimeout;
}
u_int32_t sfl_receiver_get_sFlowRcvrMaximumDatagramSize(SFLReceiver *receiver)
{
@@ -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 !=
0x) {
+if(receiver->sFlowRcvrTimeout
+ && receiver->sFlowRcvrTimeout != UINT32_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..80405b68a 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, 0x);
+sfl_receiver_set_sFlowRcvrTimeout(receiver, UINT32_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
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev