]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - libfrog/convert.c
xfs: fix maxicount division by zero error
[thirdparty/xfsprogs-dev.git] / libfrog / convert.c
index b36f77e497108de6f854bf90cf95dc3867384648..8d4d4077b3313b6c8061fb62f213bf0818c0f353 100644 (file)
@@ -1,19 +1,7 @@
+// 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"
@@ -59,7 +47,7 @@ cvt_s64(
                return i;
 
        /* Not all the input was consumed, return error. */
-       errno = -ERANGE;
+       errno = ERANGE;
        return INT64_MIN;
 }
 
@@ -80,7 +68,7 @@ cvt_s32(
        if (errno)
                return i;
        if (i > INT32_MAX || i < INT32_MIN) {
-               errno = -ERANGE;
+               errno = ERANGE;
                return INT32_MIN;
        }
        return i;
@@ -103,7 +91,7 @@ cvt_s16(
        if (errno)
                return i;
        if (i > INT16_MAX || i < INT16_MIN) {
-               errno = -ERANGE;
+               errno = ERANGE;
                return INT16_MIN;
        }
        return i;
@@ -117,14 +105,14 @@ cvt_s16(
  */
 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
@@ -135,7 +123,7 @@ cvt_u64(
                return i;
 
        /* Not all the input was consumed, return error. */
-       errno = -ERANGE;
+       errno = ERANGE;
        return UINT64_MAX;
 }
 
@@ -156,7 +144,7 @@ cvt_u32(
        if (errno)
                return i;
        if (i > UINT32_MAX) {
-               errno = -ERANGE;
+               errno = ERANGE;
                return UINT32_MAX;
        }
        return i;
@@ -179,7 +167,7 @@ cvt_u16(
        if (errno)
                return i;
        if (i > UINT16_MAX) {
-               errno = -ERANGE;
+               errno = ERANGE;
                return UINT16_MAX;
        }
        return i;