From aa074b9c43f69aa62adb15e3342a0ef63f625678 Mon Sep 17 00:00:00 2001
From: landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Date: Sun, 18 Jun 2006 20:20:07 +0000
Subject: skip_whitespace() shouldn't claim its return value is const, it
 doesn't know that and callers wind up typecasting it back.

git-svn-id: svn://busybox.net/trunk/busybox@15420 69ca8d6d-28ef-0310-b511-8ec308f3f277
---
 libbb/dump.c            | 33 +++++++++++++++------------------
 libbb/inet_common.c     |  2 +-
 libbb/pw_encrypt.c      |  2 +-
 libbb/skip_whitespace.c | 23 ++++-------------------
 4 files changed, 21 insertions(+), 39 deletions(-)

(limited to 'libbb')

diff --git a/libbb/dump.c b/libbb/dump.c
index 1a54ebbd9..b12a8e223 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -10,11 +10,10 @@
  * Original copyright notice is retained at the end of this file.
  */
 
-#include <stdlib.h>
+#include "libbb.h"
 #include <string.h>
 #include <unistd.h>
 #include <ctype.h>		/* for isdigit() */
-#include "libbb.h"
 #include "dump.h"
 
 enum _vflag bb_dump_vflag = FIRST;
@@ -83,9 +82,9 @@ int bb_dump_size(FS * fs)
 static void rewrite(FS * fs)
 {
 	enum { NOTOKAY, USEBCNT, USEPREC } sokay;
-	register PR *pr, **nextpr = NULL;
-	register FU *fu;
-	register char *p1, *p2, *p3;
+	PR *pr, **nextpr = NULL;
+	FU *fu;
+	char *p1, *p2, *p3;
 	char savech, *fmtp;
 	const char *byte_count_str;
 	int nconv, prec = 0;
@@ -98,7 +97,7 @@ static void rewrite(FS * fs)
 		for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
 			/* NOSTRICT */
 			/* DBU:[dvae@cray.com] calloc so that forward ptrs start out NULL*/
-			pr = (PR *) xzalloc(sizeof(PR));
+			pr = xzalloc(sizeof(PR));
 			if (!fu->nextpr)
 				fu->nextpr = pr;
 			/* ignore nextpr -- its unused inside the loop and is
@@ -246,8 +245,7 @@ static void rewrite(FS * fs)
 			{
 				savech = *p3;
 				*p3 = '\0';
-				if (!(pr->fmt = realloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1)))
-					bb_perror_msg_and_die("hexdump");
+				pr->fmt = xrealloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1);
 				strcat(pr->fmt, p2);
 				*p3 = savech;
 				p2 = p3;
@@ -673,17 +671,16 @@ int bb_dump_dump(char **argv)
 
 void bb_dump_add(const char *fmt)
 {
-	register const char *p;
-	register char *p1;
-	register char *p2;
+	const char *p;
+	char *p1;
+	char *p2;
 	static FS **nextfs;
 	FS *tfs;
 	FU *tfu, **nextfu;
 	const char *savep;
 
 	/* start new linked list of format units */
-	/* NOSTRICT */
-	tfs = (FS *) xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */
+	tfs = xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */
 	if (!bb_dump_fshead) {
 		bb_dump_fshead = tfs;
 	} else {
@@ -695,7 +692,7 @@ void bb_dump_add(const char *fmt)
 	/* take the format string and break it up into format units */
 	for (p = fmt;;) {
 		/* bb_dump_skip leading white space */
-		p = bb_skip_whitespace(p);
+		p = skip_whitespace(p);
 		if (!*p) {
 			break;
 		}
@@ -703,7 +700,7 @@ void bb_dump_add(const char *fmt)
 		/* allocate a new format unit and link it in */
 		/* NOSTRICT */
 		/* DBU:[dave@cray.com] calloc so that forward pointers start out NULL */
-		tfu = (FU *) xzalloc(sizeof(FU));
+		tfu = xzalloc(sizeof(FU));
 		*nextfu = tfu;
 		nextfu = &tfu->nextfu;
 		tfu->reps = 1;
@@ -718,12 +715,12 @@ void bb_dump_add(const char *fmt)
 			tfu->reps = atoi(savep);
 			tfu->flags = F_SETREP;
 			/* bb_dump_skip trailing white space */
-			p = bb_skip_whitespace(++p);
+			p = skip_whitespace(++p);
 		}
 
 		/* bb_dump_skip slash and trailing white space */
 		if (*p == '/') {
-			p = bb_skip_whitespace(++p);
+			p = skip_whitespace(++p);
 		}
 
 		/* byte count */
@@ -734,7 +731,7 @@ void bb_dump_add(const char *fmt)
 			}
 			tfu->bcnt = atoi(savep);
 			/* bb_dump_skip trailing white space */
-			p = bb_skip_whitespace(++p);
+			p = skip_whitespace(++p);
 		}
 
 		/* format */
diff --git a/libbb/inet_common.c b/libbb/inet_common.c
index c02c732f3..0051edbdc 100644
--- a/libbb/inet_common.c
+++ b/libbb/inet_common.c
@@ -8,13 +8,13 @@
  *
  */
 
+#include "libbb.h"
 #include "inet_common.h"
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "libbb.h"
 
 #ifdef DEBUG
 # include <resolv.h>
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c
index a15339974..94967133c 100644
--- a/libbb/pw_encrypt.c
+++ b/libbb/pw_encrypt.c
@@ -20,9 +20,9 @@
  *
  */
 
+#include "libbb.h"
 #include <string.h>
 #include <crypt.h>
-#include "libbb.h"
 
 
 char *pw_encrypt(const char *clear, const char *salt)
diff --git a/libbb/skip_whitespace.c b/libbb/skip_whitespace.c
index fd5d72540..02c1f5828 100644
--- a/libbb/skip_whitespace.c
+++ b/libbb/skip_whitespace.c
@@ -4,30 +4,15 @@
  *
  * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
  *
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will 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 to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
 #include <ctype.h>
 #include "libbb.h"
 
-const char *bb_skip_whitespace(const char *s)
+char *skip_whitespace(const char *s)
 {
-	while (isspace(*s)) {
-		++s;
-	}
+	while (isspace(*s)) ++s;
 
-	return s;
+	return (char *) s;
 }
-- 
cgit v1.2.3-55-g6feb