diff mbox series

[RFC,05/14] router: redefine ra_mininterval and ra_maxinterval as uint32_t

Message ID 20240509223213.97389-6-newtwen+github@gmail.com
State Changes Requested
Delegated to: Ansuel Smith
Headers show
Series odhcpd config value clamping | expand

Commit Message

Paul Donald May 9, 2024, 10:30 p.m. UTC
From: Paul Donald <newtwen@gmail.com>

They never store negative values.

Signed-off-by: Paul Donald <newtwen@gmail.com>
---
 src/config.c | 6 +++---
 src/odhcpd.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/src/config.c b/src/config.c
index 2ccf742..a3bf1ba 100644
--- a/src/config.c
+++ b/src/config.c
@@ -991,8 +991,8 @@  int config_parse_interface(void *data, size_t len, const char *name, bool overwr
 	if ((c = tb[IFACE_ATTR_RA_MININTERVAL])){
 		uint32_t ra_mininterval = blobmsg_get_u32(c);
 		iface->ra_mininterval = (ra_mininterval < MinRtrAdvInterval_FLOOR) ? // clamp min
-			MinRtrAdvInterval_FLOOR : (ra_mininterval > 0.75 * (uint32_t)iface->ra_maxinterval) ? // clamp max
-				0.75 * (uint32_t)iface->ra_maxinterval : ra_mininterval;
+			MinRtrAdvInterval_FLOOR : (ra_mininterval > 0.75 * iface->ra_maxinterval) ? // clamp max
+				0.75 * iface->ra_maxinterval : ra_mininterval;
 	}
 
 	/* 
@@ -1004,7 +1004,7 @@  int config_parse_interface(void *data, size_t len, const char *name, bool overwr
 	if ((c = tb[IFACE_ATTR_RA_LIFETIME])){
 		uint32_t ra_lifetime = blobmsg_get_u32(c);
 		iface->ra_lifetime = (ra_lifetime == 0) ? 0 : // leave at 0
-			(ra_lifetime < (uint32_t)iface->ra_maxinterval) ? (uint32_t)iface->ra_maxinterval : // clamp min
+			(ra_lifetime < iface->ra_maxinterval) ? iface->ra_maxinterval : // clamp min
 				(ra_lifetime > AdvDefaultLifetime_CEILING) ? 
 					AdvDefaultLifetime_CEILING : ra_lifetime; // clamp max
 	}
diff --git a/src/odhcpd.h b/src/odhcpd.h
index 09cd4f1..fecd77e 100644
--- a/src/odhcpd.h
+++ b/src/odhcpd.h
@@ -312,8 +312,8 @@  struct interface {
 	struct in6_addr pio_filter_addr;
 	int default_router;
 	int route_preference;
-	int ra_maxinterval;
-	int ra_mininterval;
+	uint32_t ra_maxinterval;
+	uint32_t ra_mininterval;
 	uint32_t ra_lifetime;
 	uint32_t ra_reachabletime;
 	uint32_t ra_retranstime;