lkml.org 
[lkml]   [2018]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 01/45] Use UINT_MAX, not -1, to represent an invalid UID, GID or project ID
From
Date
On 04/01/2018 01:40 PM, David Howells wrote:
> Use UINT_MAX, not -1, to represent an invalid UID, GID or project ID as the
> parameter is an unsigned integer.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
>
> include/linux/projid.h | 2 +-
> include/linux/uidgid.h | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/projid.h b/include/linux/projid.h
> index 613730622a1a..7c60a79424c9 100644
> --- a/include/linux/projid.h
> +++ b/include/linux/projid.h
> @@ -30,7 +30,7 @@ static inline projid_t __kprojid_val(kprojid_t projid)

+#include <linux/kernel.h>

> #define KPROJIDT_INIT(value) (kprojid_t){ value }
>
> -#define INVALID_PROJID KPROJIDT_INIT(-1)
> +#define INVALID_PROJID KPROJIDT_INIT(UINT_MAX)
> #define OVERFLOW_PROJID 65534
>
> static inline bool projid_eq(kprojid_t left, kprojid_t right)
> diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
> index b0542cd11aeb..75f602075b63 100644
> --- a/include/linux/uidgid.h
> +++ b/include/linux/uidgid.h
> @@ -55,8 +55,8 @@ static inline gid_t __kgid_val(kgid_t gid)

+#include <linux/kernel.h>

> #define GLOBAL_ROOT_UID KUIDT_INIT(0)
> #define GLOBAL_ROOT_GID KGIDT_INIT(0)
>
> -#define INVALID_UID KUIDT_INIT(-1)
> -#define INVALID_GID KGIDT_INIT(-1)
> +#define INVALID_UID KUIDT_INIT(UINT_MAX)
> +#define INVALID_GID KGIDT_INIT(UINT_MAX)
>
> static inline bool uid_eq(kuid_t left, kuid_t right)
> {
>


--
~Randy

\
 
 \ /
  Last update: 2018-04-02 01:05    [W:0.088 / U:2.124 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site