util.c 383 Bytes
Newer Older
1
#include <linux/dcache.h>
2
#include "internal.h"
3 4 5 6 7 8 9 10 11

unsigned name_to_int(const struct qstr *qstr)
{
	const char *name = qstr->name;
	int len = qstr->len;
	unsigned n = 0;

	if (len > 1 && *name == '0')
		goto out;
12
	do {
13 14 15 16 17 18 19
		unsigned c = *name++ - '0';
		if (c > 9)
			goto out;
		if (n >= (~0U-9)/10)
			goto out;
		n *= 10;
		n += c;
20
	} while (--len > 0);
21 22 23 24
	return n;
out:
	return ~0U;
}