LinuxKPI: Convert Linux integer types to ISO C99 in linux/kstrtox.h

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45465
This commit is contained in:
Vladimir Kondratyev 2024-06-06 23:42:07 +03:00
parent d207a2dee3
commit db42bd1f71

View file

@ -137,7 +137,7 @@ kstrtouint(const char *cp, unsigned int base, unsigned int *res)
} }
static inline int static inline int
kstrtou8(const char *cp, unsigned int base, u8 *res) kstrtou8(const char *cp, unsigned int base, uint8_t *res)
{ {
char *end; char *end;
unsigned long temp; unsigned long temp;
@ -149,13 +149,13 @@ kstrtou8(const char *cp, unsigned int base, u8 *res)
end++; end++;
if (*cp == 0 || *end != 0) if (*cp == 0 || *end != 0)
return (-EINVAL); return (-EINVAL);
if (temp != (u8)temp) if (temp != (uint8_t)temp)
return (-ERANGE); return (-ERANGE);
return (0); return (0);
} }
static inline int static inline int
kstrtou16(const char *cp, unsigned int base, u16 *res) kstrtou16(const char *cp, unsigned int base, uint16_t *res)
{ {
char *end; char *end;
unsigned long temp; unsigned long temp;
@ -167,20 +167,20 @@ kstrtou16(const char *cp, unsigned int base, u16 *res)
end++; end++;
if (*cp == 0 || *end != 0) if (*cp == 0 || *end != 0)
return (-EINVAL); return (-EINVAL);
if (temp != (u16)temp) if (temp != (uint16_t)temp)
return (-ERANGE); return (-ERANGE);
return (0); return (0);
} }
static inline int static inline int
kstrtou32(const char *cp, unsigned int base, u32 *res) kstrtou32(const char *cp, unsigned int base, uint32_t *res)
{ {
return (kstrtouint(cp, base, res)); return (kstrtouint(cp, base, res));
} }
static inline int static inline int
kstrtos64(const char *cp, unsigned int base, s64 *res) kstrtos64(const char *cp, unsigned int base, int64_t *res)
{ {
char *end; char *end;
@ -197,7 +197,7 @@ kstrtos64(const char *cp, unsigned int base, s64 *res)
static inline int static inline int
kstrtoll(const char *cp, unsigned int base, long long *res) kstrtoll(const char *cp, unsigned int base, long long *res)
{ {
return (kstrtos64(cp, base, (s64 *)res)); return (kstrtos64(cp, base, (int64_t *)res));
} }
static inline int static inline int
@ -218,7 +218,7 @@ kstrtou64(const char *cp, unsigned int base, u64 *res)
static inline int static inline int
kstrtoull(const char *cp, unsigned int base, unsigned long long *res) kstrtoull(const char *cp, unsigned int base, unsigned long long *res)
{ {
return (kstrtou64(cp, base, (u64 *)res)); return (kstrtou64(cp, base, (uint64_t *)res));
} }
static inline int static inline int
@ -301,7 +301,7 @@ kstrtou32_from_user(const char __user *s, size_t count, unsigned int base,
static inline int static inline int
kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, kstrtou8_from_user(const char __user *s, size_t count, unsigned int base,
u8 *p) uint8_t *p)
{ {
char buf[8] = {}; char buf[8] = {};