Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'uapi-use-uapi-definitions-of-int_max-and-int_min'

Thomas Weißschuh says:

====================
uapi: Use UAPI definitions of INT_MAX and INT_MIN

Using <limits.h> to gain access to INT_MAX and INT_MIN introduces a
dependency on a libc, which UAPI headers should not do.

Introduce and use equivalent UAPI constants.
====================

Link: https://patch.msgid.link/20260113-uapi-limits-v2-0-93c20f4b2c1a@linutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+20 -20
+2 -5
include/uapi/linux/ethtool.h
··· 15 15 #define _UAPI_LINUX_ETHTOOL_H 16 16 17 17 #include <linux/const.h> 18 + #include <linux/typelimits.h> 18 19 #include <linux/types.h> 19 20 #include <linux/if_ether.h> 20 - 21 - #ifndef __KERNEL__ 22 - #include <limits.h> /* for INT_MAX */ 23 - #endif 24 21 25 22 /* All structures exposed to userland should be defined such that they 26 23 * have the same layout for 32-bit and 64-bit userland. ··· 2213 2216 2214 2217 static inline int ethtool_validate_speed(__u32 speed) 2215 2218 { 2216 - return speed <= INT_MAX || speed == (__u32)SPEED_UNKNOWN; 2219 + return speed <= __KERNEL_INT_MAX || speed == (__u32)SPEED_UNKNOWN; 2217 2220 } 2218 2221 2219 2222 /* Duplex, half or full. */
+3 -6
include/uapi/linux/netfilter_bridge.h
··· 10 10 #include <linux/if_ether.h> 11 11 #include <linux/if_vlan.h> 12 12 #include <linux/if_pppox.h> 13 - 14 - #ifndef __KERNEL__ 15 - #include <limits.h> /* for INT_MIN, INT_MAX */ 16 - #endif 13 + #include <linux/typelimits.h> 17 14 18 15 /* Bridge Hooks */ 19 16 /* After promisc drops, checksum checks. */ ··· 28 31 #define NF_BR_NUMHOOKS 6 29 32 30 33 enum nf_br_hook_priorities { 31 - NF_BR_PRI_FIRST = INT_MIN, 34 + NF_BR_PRI_FIRST = __KERNEL_INT_MIN, 32 35 NF_BR_PRI_NAT_DST_BRIDGED = -300, 33 36 NF_BR_PRI_FILTER_BRIDGED = -200, 34 37 NF_BR_PRI_BRNF = 0, 35 38 NF_BR_PRI_NAT_DST_OTHER = 100, 36 39 NF_BR_PRI_FILTER_OTHER = 200, 37 40 NF_BR_PRI_NAT_SRC = 300, 38 - NF_BR_PRI_LAST = INT_MAX, 41 + NF_BR_PRI_LAST = __KERNEL_INT_MAX, 39 42 }; 40 43 41 44 #endif /* _UAPI__LINUX_BRIDGE_NETFILTER_H */
+4 -5
include/uapi/linux/netfilter_ipv4.h
··· 7 7 8 8 9 9 #include <linux/netfilter.h> 10 + #include <linux/typelimits.h> 10 11 11 12 /* only for userspace compatibility */ 12 13 #ifndef __KERNEL__ 13 - 14 - #include <limits.h> /* for INT_MIN, INT_MAX */ 15 14 16 15 /* IP Hooks */ 17 16 /* After promisc drops, checksum checks. */ ··· 27 28 #endif /* ! __KERNEL__ */ 28 29 29 30 enum nf_ip_hook_priorities { 30 - NF_IP_PRI_FIRST = INT_MIN, 31 + NF_IP_PRI_FIRST = __KERNEL_INT_MIN, 31 32 NF_IP_PRI_RAW_BEFORE_DEFRAG = -450, 32 33 NF_IP_PRI_CONNTRACK_DEFRAG = -400, 33 34 NF_IP_PRI_RAW = -300, ··· 40 41 NF_IP_PRI_NAT_SRC = 100, 41 42 NF_IP_PRI_SELINUX_LAST = 225, 42 43 NF_IP_PRI_CONNTRACK_HELPER = 300, 43 - NF_IP_PRI_CONNTRACK_CONFIRM = INT_MAX, 44 - NF_IP_PRI_LAST = INT_MAX, 44 + NF_IP_PRI_CONNTRACK_CONFIRM = __KERNEL_INT_MAX, 45 + NF_IP_PRI_LAST = __KERNEL_INT_MAX, 45 46 }; 46 47 47 48 /* Arguments for setsockopt SOL_IP: */
+3 -4
include/uapi/linux/netfilter_ipv6.h
··· 10 10 11 11 12 12 #include <linux/netfilter.h> 13 + #include <linux/typelimits.h> 13 14 14 15 /* only for userspace compatibility */ 15 16 #ifndef __KERNEL__ 16 - 17 - #include <limits.h> /* for INT_MIN, INT_MAX */ 18 17 19 18 /* IP6 Hooks */ 20 19 /* After promisc drops, checksum checks. */ ··· 31 32 32 33 33 34 enum nf_ip6_hook_priorities { 34 - NF_IP6_PRI_FIRST = INT_MIN, 35 + NF_IP6_PRI_FIRST = __KERNEL_INT_MIN, 35 36 NF_IP6_PRI_RAW_BEFORE_DEFRAG = -450, 36 37 NF_IP6_PRI_CONNTRACK_DEFRAG = -400, 37 38 NF_IP6_PRI_RAW = -300, ··· 44 45 NF_IP6_PRI_NAT_SRC = 100, 45 46 NF_IP6_PRI_SELINUX_LAST = 225, 46 47 NF_IP6_PRI_CONNTRACK_HELPER = 300, 47 - NF_IP6_PRI_LAST = INT_MAX, 48 + NF_IP6_PRI_LAST = __KERNEL_INT_MAX, 48 49 }; 49 50 50 51
+8
include/uapi/linux/typelimits.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 + #ifndef _UAPI_LINUX_TYPELIMITS_H 3 + #define _UAPI_LINUX_TYPELIMITS_H 4 + 5 + #define __KERNEL_INT_MAX ((int)(~0U >> 1)) 6 + #define __KERNEL_INT_MIN (-__KERNEL_INT_MAX - 1) 7 + 8 + #endif /* _UAPI_LINUX_TYPELIMITS_H */