1 #ifndef _LTTNG_WRAPPER_KSTRTOX_H
2 #define _LTTNG_WRAPPER_KSTRTOX_H
7 * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; only
12 * version 2.1 of the License.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <linux/version.h>
26 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0))
28 /* Excludes final \0. */
29 #define LTTNG_MAX_UINT_CHAR 10
32 int __must_check
lttng_kstrtouint_from_user(const char __user
*ubuf
,
33 size_t count
, unsigned int base
, unsigned int *res
)
36 char kbuf
[LTTNG_MAX_UINT_CHAR
+ 1], *endptr
;
38 memset(kbuf
, 0, sizeof(kbuf
));
39 if (copy_from_user(kbuf
, ubuf
, min_t(size_t, LTTNG_MAX_UINT_CHAR
, count
)))
42 _res
= simple_strtoul(kbuf
, &endptr
, base
);
51 int __must_check
lttng_kstrtouint_from_user(const char __user
*ubuf
,
52 size_t count
, unsigned int base
, unsigned int *res
)
54 return kstrtouint_from_user(ubuf
, count
, base
, res
);
58 #endif /* _LTTNG_WRAPPER_KSTRTOX_H */
This page took 0.030566 seconds and 4 git commands to generate.