From 56c5da3030bfc03476949d8281af68b76090d2c3 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 13 Jun 2016 08:21:06 -0600 Subject: [PATCH] Cosmetic change from review of PR53 --- libc/stdlib/lib_checkbase.c | 12 ++++-------- libc/stdlib/lib_strtoul.c | 15 ++++++--------- libc/stdlib/lib_strtoull.c | 18 ++++++++---------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/libc/stdlib/lib_checkbase.c b/libc/stdlib/lib_checkbase.c index d291eefc4e..a94140e81e 100644 --- a/libc/stdlib/lib_checkbase.c +++ b/libc/stdlib/lib_checkbase.c @@ -1,7 +1,7 @@ /**************************************************************************** * libc/stdlib/lib_checkbase.c * - * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,10 +44,6 @@ #include "libc.h" -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -72,7 +68,7 @@ int lib_checkbase(int base, FAR const char **pptr) { - const char *ptr = *pptr; + FAR const char *ptr = *pptr; /* Check for unspecified base */ @@ -113,9 +109,10 @@ int lib_checkbase(int base, FAR const char **pptr) } /* Check for incorrect bases. */ + else if (base < 2 || base > 26) { - return -1; /* Means incorrect base */ + return -1; /* Means incorrect base */ } /* Return the updated pointer and base */ @@ -123,4 +120,3 @@ int lib_checkbase(int base, FAR const char **pptr) *pptr = ptr; return base; } - diff --git a/libc/stdlib/lib_strtoul.c b/libc/stdlib/lib_strtoul.c index 144e68bf54..9500947ec1 100644 --- a/libc/stdlib/lib_strtoul.c +++ b/libc/stdlib/lib_strtoul.c @@ -1,7 +1,7 @@ /**************************************************************************** * /libc/stdlib/lib_strtoul.c * - * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,10 +43,6 @@ #include "libc.h" -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -69,7 +65,8 @@ unsigned long strtoul(FAR const char *nptr, FAR char **endptr, int base) { - unsigned long prev, accum = 0; + unsigned long accum = 0; + unsigned long prev; int value; if (nptr) @@ -100,9 +97,9 @@ unsigned long strtoul(FAR const char *nptr, FAR char **endptr, int base) if (accum < prev) { - set_errno(ERANGE); - accum = 0; - break; + set_errno(ERANGE); + accum = 0; + break; } } diff --git a/libc/stdlib/lib_strtoull.c b/libc/stdlib/lib_strtoull.c index b662ff65c4..0ded0af961 100644 --- a/libc/stdlib/lib_strtoull.c +++ b/libc/stdlib/lib_strtoull.c @@ -1,7 +1,7 @@ /**************************************************************************** * /libc/stdlib/lib_strtoull.c * - * Copyright (C) 2009, 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2010, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,10 +46,6 @@ #ifdef CONFIG_HAVE_LONG_LONG -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -72,7 +68,8 @@ unsigned long long strtoull(FAR const char *nptr, FAR char **endptr, int base) { - unsigned long long prev, accum = 0; + unsigned long long accum = 0; + unsigned long long prev; int value; if (nptr) @@ -103,9 +100,9 @@ unsigned long long strtoull(FAR const char *nptr, FAR char **endptr, int base) if (accum < prev) { - set_errno(ERANGE); - accum = 0; - break; + set_errno(ERANGE); + accum = 0; + break; } } @@ -116,7 +113,8 @@ unsigned long long strtoull(FAR const char *nptr, FAR char **endptr, int base) *endptr = (char *)nptr; } } - return accum; + + return accum; } #endif