1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
5 * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
8 #ifndef _LTTNG_WRAPPER_KSTRTOX_H
9 #define _LTTNG_WRAPPER_KSTRTOX_H
11 #include <linux/version.h>
13 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0))
15 #include <linux/uaccess.h>
17 /* Excludes final \0. */
18 #define LTTNG_MAX_UINT_CHAR 10
21 int __must_check
lttng_kstrtouint_from_user(const char __user
*ubuf
,
22 size_t count
, unsigned int base
, unsigned int *res
)
25 char kbuf
[LTTNG_MAX_UINT_CHAR
+ 1], *endptr
;
27 memset(kbuf
, 0, sizeof(kbuf
));
28 if (copy_from_user(kbuf
, ubuf
, min_t(size_t, LTTNG_MAX_UINT_CHAR
, count
)))
31 _res
= simple_strtoul(kbuf
, &endptr
, base
);
40 int __must_check
lttng_kstrtouint_from_user(const char __user
*ubuf
,
41 size_t count
, unsigned int base
, unsigned int *res
)
43 return kstrtouint_from_user(ubuf
, count
, base
, res
);
47 #endif /* _LTTNG_WRAPPER_KSTRTOX_H */
This page took 0.041112 seconds and 4 git commands to generate.