summaryrefslogtreecommitdiff
path: root/pkg/iproute2/patch/0012-Use-static-inline-function-for-min.patch
blob: 5c1fbe49bb78276e07c7a54414e13195638b4702 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From 610a720da48cb1b4de2364d70215450275edebcb Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Mon, 24 Jun 2019 17:38:56 -0700
Subject: [PATCH] Use static inline function for min()

It is only called to calculate a minimum `int`, so specialize for
`int`.
---
 include/utils.h | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/utils.h b/include/utils.h
index b6c468e9..8bdbb369 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -273,13 +273,10 @@ unsigned int print_name_and_link(const char *fmt,
 # define offsetof(type, member) ((size_t) &((type *)0)->member)
 #endif
 
-#ifndef min
-# define min(x, y) ({			\
-	typeof(x) _min1 = (x);		\
-	typeof(y) _min2 = (y);		\
-	(void) (&_min1 == &_min2);	\
-	_min1 < _min2 ? _min1 : _min2; })
-#endif
+static inline int min(int a, int b)
+{
+	return a < b ? a : b;
+}
 
 #ifndef __check_format_string
 # define __check_format_string(pos_str, pos_args) \
-- 
2.34.1