Merge tag 'kbuild-v5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
[linux-block.git] / fs / proc / util.c
CommitLineData
3ee2a199 1#include <linux/dcache.h>
81966d83 2#include "internal.h"
3ee2a199
AD
3
4unsigned name_to_int(const struct qstr *qstr)
5{
6 const char *name = qstr->name;
7 int len = qstr->len;
8 unsigned n = 0;
9
10 if (len > 1 && *name == '0')
11 goto out;
0746a0bc 12 do {
3ee2a199
AD
13 unsigned c = *name++ - '0';
14 if (c > 9)
15 goto out;
16 if (n >= (~0U-9)/10)
17 goto out;
18 n *= 10;
19 n += c;
0746a0bc 20 } while (--len > 0);
3ee2a199
AD
21 return n;
22out:
23 return ~0U;
24}