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