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

Paul Donald newtwen+github at gmail.com
Thu May 9 15:30:37 PDT 2024


From: Paul Donald <newtwen at gmail.com>

They never store negative values.

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

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;
-- 
2.44.0




More information about the openwrt-devel mailing list