aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-06-18 20:20:07 +0000
committerRob Landley <rob@landley.net>2006-06-18 20:20:07 +0000
commitea224be6aa8fed5486376d3021a4cb911e935106 (patch)
tree38d6c5d2d53841e3f4e2702521e3b03235c51017 /libbb
parent14d7065ef1eb836d20e13bc25d1b13f0e76185ac (diff)
downloadbusybox-w32-ea224be6aa8fed5486376d3021a4cb911e935106.tar.gz
busybox-w32-ea224be6aa8fed5486376d3021a4cb911e935106.tar.bz2
busybox-w32-ea224be6aa8fed5486376d3021a4cb911e935106.zip
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 1a54ebbd9..b12a8e223 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -10,11 +10,10 @@
10 * Original copyright notice is retained at the end of this file. 10 * Original copyright notice is retained at the end of this file.
11 */ 11 */
12 12
13#include <stdlib.h> 13#include "libbb.h"
14#include <string.h> 14#include <string.h>
15#include <unistd.h> 15#include <unistd.h>
16#include <ctype.h> /* for isdigit() */ 16#include <ctype.h> /* for isdigit() */
17#include "libbb.h"
18#include "dump.h" 17#include "dump.h"
19 18
20enum _vflag bb_dump_vflag = FIRST; 19enum _vflag bb_dump_vflag = FIRST;
@@ -83,9 +82,9 @@ int bb_dump_size(FS * fs)
83static void rewrite(FS * fs) 82static void rewrite(FS * fs)
84{ 83{
85 enum { NOTOKAY, USEBCNT, USEPREC } sokay; 84 enum { NOTOKAY, USEBCNT, USEPREC } sokay;
86 register PR *pr, **nextpr = NULL; 85 PR *pr, **nextpr = NULL;
87 register FU *fu; 86 FU *fu;
88 register char *p1, *p2, *p3; 87 char *p1, *p2, *p3;
89 char savech, *fmtp; 88 char savech, *fmtp;
90 const char *byte_count_str; 89 const char *byte_count_str;
91 int nconv, prec = 0; 90 int nconv, prec = 0;
@@ -98,7 +97,7 @@ static void rewrite(FS * fs)
98 for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) { 97 for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
99 /* NOSTRICT */ 98 /* NOSTRICT */
100 /* DBU:[dvae@cray.com] calloc so that forward ptrs start out NULL*/ 99 /* DBU:[dvae@cray.com] calloc so that forward ptrs start out NULL*/
101 pr = (PR *) xzalloc(sizeof(PR)); 100 pr = xzalloc(sizeof(PR));
102 if (!fu->nextpr) 101 if (!fu->nextpr)
103 fu->nextpr = pr; 102 fu->nextpr = pr;
104 /* ignore nextpr -- its unused inside the loop and is 103 /* ignore nextpr -- its unused inside the loop and is
@@ -246,8 +245,7 @@ static void rewrite(FS * fs)
246 { 245 {
247 savech = *p3; 246 savech = *p3;
248 *p3 = '\0'; 247 *p3 = '\0';
249 if (!(pr->fmt = realloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1))) 248 pr->fmt = xrealloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1);
250 bb_perror_msg_and_die("hexdump");
251 strcat(pr->fmt, p2); 249 strcat(pr->fmt, p2);
252 *p3 = savech; 250 *p3 = savech;
253 p2 = p3; 251 p2 = p3;
@@ -673,17 +671,16 @@ int bb_dump_dump(char **argv)
673 671
674void bb_dump_add(const char *fmt) 672void bb_dump_add(const char *fmt)
675{ 673{
676 register const char *p; 674 const char *p;
677 register char *p1; 675 char *p1;
678 register char *p2; 676 char *p2;
679 static FS **nextfs; 677 static FS **nextfs;
680 FS *tfs; 678 FS *tfs;
681 FU *tfu, **nextfu; 679 FU *tfu, **nextfu;
682 const char *savep; 680 const char *savep;
683 681
684 /* start new linked list of format units */ 682 /* start new linked list of format units */
685 /* NOSTRICT */ 683 tfs = xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */
686 tfs = (FS *) xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */
687 if (!bb_dump_fshead) { 684 if (!bb_dump_fshead) {
688 bb_dump_fshead = tfs; 685 bb_dump_fshead = tfs;
689 } else { 686 } else {
@@ -695,7 +692,7 @@ void bb_dump_add(const char *fmt)
695 /* take the format string and break it up into format units */ 692 /* take the format string and break it up into format units */
696 for (p = fmt;;) { 693 for (p = fmt;;) {
697 /* bb_dump_skip leading white space */ 694 /* bb_dump_skip leading white space */
698 p = bb_skip_whitespace(p); 695 p = skip_whitespace(p);
699 if (!*p) { 696 if (!*p) {
700 break; 697 break;
701 } 698 }
@@ -703,7 +700,7 @@ void bb_dump_add(const char *fmt)
703 /* allocate a new format unit and link it in */ 700 /* allocate a new format unit and link it in */
704 /* NOSTRICT */ 701 /* NOSTRICT */
705 /* DBU:[dave@cray.com] calloc so that forward pointers start out NULL */ 702 /* DBU:[dave@cray.com] calloc so that forward pointers start out NULL */
706 tfu = (FU *) xzalloc(sizeof(FU)); 703 tfu = xzalloc(sizeof(FU));
707 *nextfu = tfu; 704 *nextfu = tfu;
708 nextfu = &tfu->nextfu; 705 nextfu = &tfu->nextfu;
709 tfu->reps = 1; 706 tfu->reps = 1;
@@ -718,12 +715,12 @@ void bb_dump_add(const char *fmt)
718 tfu->reps = atoi(savep); 715 tfu->reps = atoi(savep);
719 tfu->flags = F_SETREP; 716 tfu->flags = F_SETREP;
720 /* bb_dump_skip trailing white space */ 717 /* bb_dump_skip trailing white space */
721 p = bb_skip_whitespace(++p); 718 p = skip_whitespace(++p);
722 } 719 }
723 720
724 /* bb_dump_skip slash and trailing white space */ 721 /* bb_dump_skip slash and trailing white space */
725 if (*p == '/') { 722 if (*p == '/') {
726 p = bb_skip_whitespace(++p); 723 p = skip_whitespace(++p);
727 } 724 }
728 725
729 /* byte count */ 726 /* byte count */
@@ -734,7 +731,7 @@ void bb_dump_add(const char *fmt)
734 } 731 }
735 tfu->bcnt = atoi(savep); 732 tfu->bcnt = atoi(savep);
736 /* bb_dump_skip trailing white space */ 733 /* bb_dump_skip trailing white space */
737 p = bb_skip_whitespace(++p); 734 p = skip_whitespace(++p);
738 } 735 }
739 736
740 /* format */ 737 /* 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 @@
8 * 8 *
9 */ 9 */
10 10
11#include "libbb.h"
11#include "inet_common.h" 12#include "inet_common.h"
12#include <stdio.h> 13#include <stdio.h>
13#include <errno.h> 14#include <errno.h>
14#include <stdlib.h> 15#include <stdlib.h>
15#include <string.h> 16#include <string.h>
16#include <unistd.h> 17#include <unistd.h>
17#include "libbb.h"
18 18
19#ifdef DEBUG 19#ifdef DEBUG
20# include <resolv.h> 20# 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 @@
20 * 20 *
21 */ 21 */
22 22
23#include "libbb.h"
23#include <string.h> 24#include <string.h>
24#include <crypt.h> 25#include <crypt.h>
25#include "libbb.h"
26 26
27 27
28char *pw_encrypt(const char *clear, const char *salt) 28char *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 @@
4 * 4 *
5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> 5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */ 8 */
22 9
23#include <ctype.h> 10#include <ctype.h>
24#include "libbb.h" 11#include "libbb.h"
25 12
26const char *bb_skip_whitespace(const char *s) 13char *skip_whitespace(const char *s)
27{ 14{
28 while (isspace(*s)) { 15 while (isspace(*s)) ++s;
29 ++s;
30 }
31 16
32 return s; 17 return (char *) s;
33} 18}