https://github.com/torvalds/linux
Raw File
Tip revision: d8a5b80568a9cb66810e75b182018e9edb68e8ff authored by Linus Torvalds on 28 January 2018, 21:20:33 UTC
Linux 4.15
Tip revision: d8a5b80
util.c
#include <linux/dcache.h>

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;
	do {
		unsigned c = *name++ - '0';
		if (c > 9)
			goto out;
		if (n >= (~0U-9)/10)
			goto out;
		n *= 10;
		n += c;
	} while (--len > 0);
	return n;
out:
	return ~0U;
}
back to top