util.c 383 B

123456789101112131415161718192021222324
  1. #include <linux/dcache.h>
  2. #include "internal.h"
  3. unsigned name_to_int(const struct qstr *qstr)
  4. {
  5. const char *name = qstr->name;
  6. int len = qstr->len;
  7. unsigned n = 0;
  8. if (len > 1 && *name == '0')
  9. goto out;
  10. do {
  11. unsigned c = *name++ - '0';
  12. if (c > 9)
  13. goto out;
  14. if (n >= (~0U-9)/10)
  15. goto out;
  16. n *= 10;
  17. n += c;
  18. } while (--len > 0);
  19. return n;
  20. out:
  21. return ~0U;
  22. }