From 78d75b1dcf0d42e6ad5ce8b7203a19e17b9c87dc Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Sun, 30 Aug 2026 02:46:44 +0300 Subject: utils: centralize max macro Closes #354 --- accel-pppd/ctrl/ipoe/dhcpv4.c | 5 +---- accel-pppd/ctrl/pptp/pptp_prot.h | 1 - accel-pppd/ctrl/sstp/sstp.c | 4 ---- accel-pppd/radius/acct.c | 5 +---- accel-pppd/utils.h | 4 ++++ 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c index f1427e17..2bd59437 100644 --- a/accel-pppd/ctrl/ipoe/dhcpv4.c +++ b/accel-pppd/ctrl/ipoe/dhcpv4.c @@ -24,15 +24,12 @@ #include "ipdb.h" #include "radius.h" #include "dhcp_attr_defs.h" +#include "utils.h" #include "dhcpv4.h" #define BUF_SIZE 4096 -#ifndef max -#define max(x,y) ((x) > (y) ? (x) : (y)) -#endif - struct dhcpv4_relay_ctx { struct list_head entry; struct triton_context_t *ctx; diff --git a/accel-pppd/ctrl/pptp/pptp_prot.h b/accel-pppd/ctrl/pptp/pptp_prot.h index ee8cb341..3726334a 100644 --- a/accel-pppd/ctrl/pptp/pptp_prot.h +++ b/accel-pppd/ctrl/pptp/pptp_prot.h @@ -281,7 +281,6 @@ struct pptp_set_link_info /* for control message type 15 */ (type==PPTP_WAN_ERR_NTFY )?sizeof(struct pptp_wan_err_ntfy): \ (type==PPTP_SET_LINK_INFO )?sizeof(struct pptp_set_link_info): \ 0) -#define max(a,b) (((a)>(b))?(a):(b)) #define PPTP_CTRL_SIZE_MAX ( \ max(sizeof(struct pptp_start_ctrl_conn), \ max(sizeof(struct pptp_echo_rqst), \ diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c index c3cd111d..0920f5af 100644 --- a/accel-pppd/ctrl/sstp/sstp.c +++ b/accel-pppd/ctrl/sstp/sstp.c @@ -50,10 +50,6 @@ #include "sstp_prot.h" #include "if_ppposeq.h" -#ifndef max -#define max(x,y) ((x) > (y) ? (x) : (y)) -#endif - #define PPP_BUF_SIZE 8192 #define PPP_BUF_IOVEC 256 #define PPP_F_ESCAPE 1 diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c index d30aae7a..0448fc95 100644 --- a/accel-pppd/radius/acct.c +++ b/accel-pppd/radius/acct.c @@ -14,15 +14,12 @@ #include "backup.h" #include "ap_session_backup.h" #include "iputils.h" +#include "utils.h" #include "radius_p.h" #include "memdebug.h" -#ifndef max -#define max(x,y) ((x) > (y) ? (x) : (y)) -#endif - #define INTERIM_SAFE_TIME 10 static int req_set_RA(struct rad_req_t *req) diff --git a/accel-pppd/utils.h b/accel-pppd/utils.h index 7c62422c..6c03299f 100644 --- a/accel-pppd/utils.h +++ b/accel-pppd/utils.h @@ -10,6 +10,10 @@ #define min(x, y) ((x) < (y) ? (x) : (y)) #endif +#ifndef max +#define max(x, y) ((x) > (y) ? (x) : (y)) +#endif + /* * Fixed-size memcpy() lets the compiler emit efficient unaligned accesses on * architectures that support them without imposing alignment or aliasing -- cgit v1.2.3