summaryrefslogtreecommitdiff
path: root/proto_ipv4.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2013-08-02 15:10:20 +0200
committerTobias Klauser <tklauser@distanz.ch>2013-08-02 15:12:29 +0200
commit98c15cbb658f226d52108ea2cb5b3bc27bc6a977 (patch)
tree74a1e2b730676a26ebf6ff9d6487e6dfc5ef012b /proto_ipv4.c
parentc95c515fa9075443900734039cfd7f92b5ba832f (diff)
built_in: Add min_t() and max_t() macros and use them
Introduce non-typechecking versions of min_t() and max_t() and use them where a cast would be needed. The macros were taken from the Linux Kernel, release under GPL v2. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'proto_ipv4.c')
-rw-r--r--proto_ipv4.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/proto_ipv4.c b/proto_ipv4.c
index e11098f..303319e 100644
--- a/proto_ipv4.c
+++ b/proto_ipv4.c
@@ -121,7 +121,7 @@ static void ipv4(struct pkt_buff *pkt)
tprintf(") ]\n");
}
- opts_len = max((uint8_t) ip->h_ihl, sizeof(*ip) / sizeof(uint32_t)) *
+ opts_len = max_t(uint8_t, ip->h_ihl, sizeof(*ip) / sizeof(uint32_t)) *
sizeof(uint32_t) - sizeof(*ip);
for (opt = pkt_pull(pkt, opts_len); opt && opts_len > 0; opt++) {
@@ -184,7 +184,7 @@ static void ipv4_less(struct pkt_buff *pkt)
ntohs(ip->h_tot_len));
/* cut off IP options and everything that is not part of IPv4 payload */
- pkt_pull(pkt, max((uint8_t) ip->h_ihl, sizeof(*ip) / sizeof(uint32_t))
+ pkt_pull(pkt, max_t(uint8_t, ip->h_ihl, sizeof(*ip) / sizeof(uint32_t))
* sizeof(uint32_t) - sizeof(*ip));
/* XXX there coul still be an Ethernet trailer included or others */
#if 0