summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRob Landley2006-06-18 20:20:07 +0000
committerRob Landley2006-06-18 20:20:07 +0000
commitea224be6aa8fed5486376d3021a4cb911e935106 (patch)
tree38d6c5d2d53841e3f4e2702521e3b03235c51017 /libbb
parent14d7065ef1eb836d20e13bc25d1b13f0e76185ac (diff)
downloadbusybox-ea224be6aa8fed5486376d3021a4cb911e935106.zip
busybox-ea224be6aa8fed5486376d3021a4cb911e935106.tar.gz
skip_whitespace() shouldn't claim its return value is const, it doesn't know
that and callers wind up typecasting it back.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/dump.c33
-rw-r--r--libbb/inet_common.c2
-rw-r--r--libbb/pw_encrypt.c2
-rw-r--r--libbb/skip_whitespace.c23
4 files changed, 21 insertions, 39 deletions
diff --git a/libbb/dump.c b/libbb/dump.c
index 1a54ebb..b12a8e2 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 c02c732..0051edb 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 a153399..9496713 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 fd5d725..02c1f58 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;
}