+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2003-2005 Silicon Graphics, Inc.
* All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "platform_defs.h"
#include "input.h"
return i;
/* Not all the input was consumed, return error. */
- errno = -ERANGE;
+ errno = ERANGE;
return INT64_MIN;
}
if (errno)
return i;
if (i > INT32_MAX || i < INT32_MIN) {
- errno = -ERANGE;
+ errno = ERANGE;
return INT32_MIN;
}
return i;
if (errno)
return i;
if (i > INT16_MAX || i < INT16_MIN) {
- errno = -ERANGE;
+ errno = ERANGE;
return INT16_MIN;
}
return i;
*/
uint64_t
cvt_u64(
- char *s,
- int base)
+ char *s,
+ int base)
{
- long long i;
- char *sp;
+ unsigned long long i;
+ char *sp;
errno = 0;
- i = strtoll(s, &sp, base);
+ i = strtoull(s, &sp, base);
/*
* If the input would over or underflow, return the clamped
* value and let the user check errno. If we went all the
return i;
/* Not all the input was consumed, return error. */
- errno = -ERANGE;
+ errno = ERANGE;
return UINT64_MAX;
}
if (errno)
return i;
if (i > UINT32_MAX) {
- errno = -ERANGE;
+ errno = ERANGE;
return UINT32_MAX;
}
return i;
if (errno)
return i;
if (i > UINT16_MAX) {
- errno = -ERANGE;
+ errno = ERANGE;
return UINT16_MAX;
}
return i;