Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/lib/strtol.c

    r9675296 r42e91ae  
    245245}
    246246
     247static inline intmax_t _strtosigned(const char *nptr, char **endptr, int base,
     248    intmax_t min, intmax_t max, errno_t *err, bool nonstd)
     249{
     250        bool sgn = false;
     251        uintmax_t number = _strtoumax(nptr, endptr, base, &sgn, err, nonstd);
     252
     253        if (number > (uintmax_t) max) {
     254                if (sgn && (number - 1 == (uintmax_t) max)) {
     255                        return min;
     256                }
     257
     258                *err = nonstd ? EOVERFLOW : ERANGE;
     259                return (sgn ? min : max);
     260        }
     261
     262        return (sgn ? -number : number);
     263}
     264
    247265static inline uintmax_t _strtounsigned(const char *nptr, char **endptr, int base,
    248266    uintmax_t max, errno_t *err, bool nonstd)
Note: See TracChangeset for help on using the changeset viewer.