diff options
author | Rob Landley <rob@landley.net> | 2006-06-25 22:39:24 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-06-25 22:39:24 +0000 |
commit | 11c7a7bed60a55a670363bec3c07e8d88aa372b7 (patch) | |
tree | 809c167b4c007b334afcb34b4689841a029022ac | |
parent | f087798e8bf5857b679c369601426ca29334caee (diff) | |
download | busybox-w32-11c7a7bed60a55a670363bec3c07e8d88aa372b7.tar.gz busybox-w32-11c7a7bed60a55a670363bec3c07e8d88aa372b7.tar.bz2 busybox-w32-11c7a7bed60a55a670363bec3c07e8d88aa372b7.zip |
Various cleanups I made while going through Erik Hovland's patch submissions,
some of which are even from him. :)
-rw-r--r-- | archival/libunarchive/decompress_unzip.c | 87 | ||||
-rw-r--r-- | e2fsprogs/ext2fs/ext_attr.c | 6 | ||||
-rw-r--r-- | miscutils/crontab.c | 2 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 45 | ||||
-rw-r--r-- | util-linux/fdisk.c | 2 |
5 files changed, 31 insertions, 111 deletions
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c index a589bdcd4..e39901c1b 100644 --- a/archival/libunarchive/decompress_unzip.c +++ b/archival/libunarchive/decompress_unzip.c | |||
@@ -21,21 +21,6 @@ | |||
21 | * to free leaked bytebuffer memory (used in unzip.c), and some minor style | 21 | * to free leaked bytebuffer memory (used in unzip.c), and some minor style |
22 | * guide cleanups by Ed Clark | 22 | * guide cleanups by Ed Clark |
23 | * | 23 | * |
24 | * This program is free software; you can redistribute it and/or modify | ||
25 | * it under the terms of the GNU General Public License as published by | ||
26 | * the Free Software Foundation; either version 2 of the License, or | ||
27 | * (at your option) any later version. | ||
28 | * | ||
29 | * This program is distributed in the hope that it will be useful, | ||
30 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
31 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
32 | * General Public License for more details. | ||
33 | * | ||
34 | * You should have received a copy of the GNU General Public License | ||
35 | * along with this program; if not, write to the Free Software | ||
36 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
37 | * | ||
38 | * | ||
39 | * gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface | 24 | * gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface |
40 | * Copyright (C) 1992-1993 Jean-loup Gailly | 25 | * Copyright (C) 1992-1993 Jean-loup Gailly |
41 | * The unzip code was written and put in the public domain by Mark Adler. | 26 | * The unzip code was written and put in the public domain by Mark Adler. |
@@ -43,38 +28,14 @@ | |||
43 | * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, | 28 | * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, |
44 | * Ken Turkowski, Dave Mack and Peter Jannesen. | 29 | * Ken Turkowski, Dave Mack and Peter Jannesen. |
45 | * | 30 | * |
46 | * See the license_msg below and the file COPYING for the software license. | ||
47 | * See the file algorithm.doc for the compression algorithms and file formats. | 31 | * See the file algorithm.doc for the compression algorithms and file formats. |
32 | * | ||
33 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
48 | */ | 34 | */ |
49 | 35 | ||
50 | #if 0 | 36 | #include "libbb.h" |
51 | static char *license_msg[] = { | ||
52 | " Copyright (C) 1992-1993 Jean-loup Gailly", | ||
53 | " This program is free software; you can redistribute it and/or modify", | ||
54 | " it under the terms of the GNU General Public License as published by", | ||
55 | " the Free Software Foundation; either version 2, or (at your option)", | ||
56 | " any later version.", | ||
57 | "", | ||
58 | " This program is distributed in the hope that it will be useful,", | ||
59 | " but WITHOUT ANY WARRANTY; without even the implied warranty of", | ||
60 | " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the", | ||
61 | " GNU General Public License for more details.", | ||
62 | "", | ||
63 | " You should have received a copy of the GNU General Public License", | ||
64 | " along with this program; if not, write to the Free Software", | ||
65 | " Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.", | ||
66 | 0 | ||
67 | }; | ||
68 | #endif | ||
69 | |||
70 | #include <sys/types.h> | ||
71 | #include <sys/wait.h> | 37 | #include <sys/wait.h> |
72 | #include <signal.h> | 38 | #include <signal.h> |
73 | #include <stdlib.h> | ||
74 | #include <string.h> | ||
75 | #include <unistd.h> | ||
76 | #include <fcntl.h> | ||
77 | #include "libbb.h" | ||
78 | #include "unarchive.h" | 39 | #include "unarchive.h" |
79 | 40 | ||
80 | typedef struct huft_s { | 41 | typedef struct huft_s { |
@@ -213,17 +174,17 @@ int huft_build(unsigned int *b, const unsigned int n, | |||
213 | unsigned eob_len; /* length of end-of-block code (value 256) */ | 174 | unsigned eob_len; /* length of end-of-block code (value 256) */ |
214 | unsigned f; /* i repeats in table every f entries */ | 175 | unsigned f; /* i repeats in table every f entries */ |
215 | int g; /* maximum code length */ | 176 | int g; /* maximum code length */ |
216 | int h; /* table level */ | 177 | int htl; /* table level */ |
217 | register unsigned i; /* counter, current code */ | 178 | unsigned i; /* counter, current code */ |
218 | register unsigned j; /* counter */ | 179 | unsigned j; /* counter */ |
219 | register int k; /* number of bits in current code */ | 180 | int k; /* number of bits in current code */ |
220 | register unsigned *p; /* pointer into c[], b[], or v[] */ | 181 | unsigned *p; /* pointer into c[], b[], or v[] */ |
221 | register huft_t *q; /* points to current table */ | 182 | huft_t *q; /* points to current table */ |
222 | huft_t r; /* table entry for structure assignment */ | 183 | huft_t r; /* table entry for structure assignment */ |
223 | huft_t *u[BMAX]; /* table stack */ | 184 | huft_t *u[BMAX]; /* table stack */ |
224 | unsigned v[N_MAX]; /* values in order of bit length */ | 185 | unsigned v[N_MAX]; /* values in order of bit length */ |
225 | int ws[BMAX+1]; /* bits decoded stack */ | 186 | int ws[BMAX+1]; /* bits decoded stack */ |
226 | register int w; /* bits decoded */ | 187 | int w; /* bits decoded */ |
227 | unsigned x[BMAX + 1]; /* bit offsets, then code stack */ | 188 | unsigned x[BMAX + 1]; /* bit offsets, then code stack */ |
228 | unsigned *xp; /* pointer into x */ | 189 | unsigned *xp; /* pointer into x */ |
229 | int y; /* number of dummy codes added */ | 190 | int y; /* number of dummy codes added */ |
@@ -284,7 +245,7 @@ int huft_build(unsigned int *b, const unsigned int n, | |||
284 | /* Generate the Huffman codes and for each, make the table entries */ | 245 | /* Generate the Huffman codes and for each, make the table entries */ |
285 | x[0] = i = 0; /* first Huffman code is zero */ | 246 | x[0] = i = 0; /* first Huffman code is zero */ |
286 | p = v; /* grab values in bit order */ | 247 | p = v; /* grab values in bit order */ |
287 | h = -1; /* no tables yet--level -1 */ | 248 | htl = -1; /* no tables yet--level -1 */ |
288 | w = ws[0] = 0; /* bits decoded */ | 249 | w = ws[0] = 0; /* bits decoded */ |
289 | u[0] = (huft_t *) NULL; /* just to keep compilers happy */ | 250 | u[0] = (huft_t *) NULL; /* just to keep compilers happy */ |
290 | q = (huft_t *) NULL; /* ditto */ | 251 | q = (huft_t *) NULL; /* ditto */ |
@@ -296,8 +257,8 @@ int huft_build(unsigned int *b, const unsigned int n, | |||
296 | while (a--) { | 257 | while (a--) { |
297 | /* here i is the Huffman code of length k bits for value *p */ | 258 | /* here i is the Huffman code of length k bits for value *p */ |
298 | /* make tables up to required level */ | 259 | /* make tables up to required level */ |
299 | while (k > ws[h + 1]) { | 260 | while (k > ws[htl + 1]) { |
300 | w = ws[++h]; | 261 | w = ws[++htl]; |
301 | 262 | ||
302 | /* compute minimum size table less than or equal to *m bits */ | 263 | /* compute minimum size table less than or equal to *m bits */ |
303 | z = (z = g - w) > *m ? *m : z; /* upper limit on table size */ | 264 | z = (z = g - w) > *m ? *m : z; /* upper limit on table size */ |
@@ -314,22 +275,22 @@ int huft_build(unsigned int *b, const unsigned int n, | |||
314 | } | 275 | } |
315 | j = (w + j > eob_len && w < eob_len) ? eob_len - w : j; /* make EOB code end at table */ | 276 | j = (w + j > eob_len && w < eob_len) ? eob_len - w : j; /* make EOB code end at table */ |
316 | z = 1 << j; /* table entries for j-bit table */ | 277 | z = 1 << j; /* table entries for j-bit table */ |
317 | ws[h+1] = w + j; /* set bits decoded in stack */ | 278 | ws[htl+1] = w + j; /* set bits decoded in stack */ |
318 | 279 | ||
319 | /* allocate and link in new table */ | 280 | /* allocate and link in new table */ |
320 | q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t)); | 281 | q = (huft_t *) xzalloc((z + 1) * sizeof(huft_t)); |
321 | *t = q + 1; /* link to list for huft_free() */ | 282 | *t = q + 1; /* link to list for huft_free() */ |
322 | *(t = &(q->v.t)) = NULL; | 283 | t = &(q->v.t); |
323 | u[h] = ++q; /* table starts after link */ | 284 | u[htl] = ++q; /* table starts after link */ |
324 | 285 | ||
325 | /* connect to last table, if there is one */ | 286 | /* connect to last table, if there is one */ |
326 | if (h) { | 287 | if (htl) { |
327 | x[h] = i; /* save pattern for backing up */ | 288 | x[htl] = i; /* save pattern for backing up */ |
328 | r.b = (unsigned char) (w - ws[h - 1]); /* bits to dump before this table */ | 289 | r.b = (unsigned char) (w - ws[htl - 1]); /* bits to dump before this table */ |
329 | r.e = (unsigned char) (16 + j); /* bits in this table */ | 290 | r.e = (unsigned char) (16 + j); /* bits in this table */ |
330 | r.v.t = q; /* pointer to this table */ | 291 | r.v.t = q; /* pointer to this table */ |
331 | j = (i & ((1 << w) - 1)) >> ws[h - 1]; | 292 | j = (i & ((1 << w) - 1)) >> ws[htl - 1]; |
332 | u[h - 1][j] = r; /* connect to last table */ | 293 | u[htl - 1][j] = r; /* connect to last table */ |
333 | } | 294 | } |
334 | } | 295 | } |
335 | 296 | ||
@@ -358,8 +319,8 @@ int huft_build(unsigned int *b, const unsigned int n, | |||
358 | i ^= j; | 319 | i ^= j; |
359 | 320 | ||
360 | /* backup over finished tables */ | 321 | /* backup over finished tables */ |
361 | while ((i & ((1 << w) - 1)) != x[h]) { | 322 | while ((i & ((1 << w) - 1)) != x[htl]) { |
362 | w = ws[--h]; | 323 | w = ws[--htl]; |
363 | } | 324 | } |
364 | } | 325 | } |
365 | } | 326 | } |
diff --git a/e2fsprogs/ext2fs/ext_attr.c b/e2fsprogs/ext2fs/ext_attr.c index 17610a914..ca9f9e20c 100644 --- a/e2fsprogs/ext2fs/ext_attr.c +++ b/e2fsprogs/ext2fs/ext_attr.c | |||
@@ -41,16 +41,14 @@ errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block, void *inbuf) | |||
41 | char *write_buf; | 41 | char *write_buf; |
42 | char *buf = NULL; | 42 | char *buf = NULL; |
43 | 43 | ||
44 | #if BB_BIG_ENDIAN | 44 | if (BB_BIG_ENDIAN && ((fs->flags & EXT2_FLAG_SWAP_BYTES) || |
45 | if ((fs->flags & EXT2_FLAG_SWAP_BYTES) || | 45 | (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))) { |
46 | (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)) { | ||
47 | retval = ext2fs_get_mem(fs->blocksize, &buf); | 46 | retval = ext2fs_get_mem(fs->blocksize, &buf); |
48 | if (retval) | 47 | if (retval) |
49 | return retval; | 48 | return retval; |
50 | write_buf = buf; | 49 | write_buf = buf; |
51 | ext2fs_swap_ext_attr(buf, inbuf, fs->blocksize, 1); | 50 | ext2fs_swap_ext_attr(buf, inbuf, fs->blocksize, 1); |
52 | } else | 51 | } else |
53 | #endif | ||
54 | write_buf = (char *) inbuf; | 52 | write_buf = (char *) inbuf; |
55 | retval = io_channel_write_blk(fs->io, block, 1, write_buf); | 53 | retval = io_channel_write_blk(fs->io, block, 1, write_buf); |
56 | if (buf) | 54 | if (buf) |
diff --git a/miscutils/crontab.c b/miscutils/crontab.c index 67279fdeb..0ed59b0dc 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c | |||
@@ -62,7 +62,7 @@ crontab_main(int ac, char **av) | |||
62 | if ((pas = getpwuid(UserId)) == NULL) | 62 | if ((pas = getpwuid(UserId)) == NULL) |
63 | bb_perror_msg_and_die("getpwuid"); | 63 | bb_perror_msg_and_die("getpwuid"); |
64 | 64 | ||
65 | strncpy(caller, pas->pw_name, sizeof(caller)); | 65 | safe_strncpy(caller, pas->pw_name, sizeof(caller)); |
66 | 66 | ||
67 | i = 1; | 67 | i = 1; |
68 | if (ac > 1) { | 68 | if (ac > 1) { |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index a1b6d4626..8c795bc62 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -61,41 +61,6 @@ struct client_config_t client_config = { | |||
61 | .arp = "\0\0\0\0\0\0", /* appease gcc-3.0 */ | 61 | .arp = "\0\0\0\0\0\0", /* appease gcc-3.0 */ |
62 | }; | 62 | }; |
63 | 63 | ||
64 | #ifndef IN_BUSYBOX | ||
65 | static void ATTRIBUTE_NORETURN show_usage(void) | ||
66 | { | ||
67 | printf( | ||
68 | "Usage: udhcpc [OPTIONS]\n\n" | ||
69 | " -c, --clientid=CLIENTID Set client identifier - type is first char\n" | ||
70 | " -C, --clientid-none Suppress default client identifier\n" | ||
71 | " -V, --vendorclass=CLASSID Set vendor class identifier\n" | ||
72 | " -H, --hostname=HOSTNAME Client hostname\n" | ||
73 | " -h Alias for -H\n" | ||
74 | " -F, --fqdn=FQDN Client fully qualified domain name\n" | ||
75 | " -f, --foreground Do not fork after getting lease\n" | ||
76 | " -b, --background Fork to background if lease cannot be\n" | ||
77 | " immediately negotiated.\n" | ||
78 | " -i, --interface=INTERFACE Interface to use (default: eth0)\n" | ||
79 | " -n, --now Exit with failure if lease cannot be\n" | ||
80 | " immediately negotiated.\n" | ||
81 | " -p, --pidfile=file Store process ID of daemon in file\n" | ||
82 | " -q, --quit Quit after obtaining lease\n" | ||
83 | " -r, --request=IP IP address to request (default: none)\n" | ||
84 | " -s, --script=file Run file at dhcp events (default:\n" | ||
85 | " " DEFAULT_SCRIPT ")\n" | ||
86 | " -T, --timeout=seconds Try to get the lease for the amount of\n" | ||
87 | " seconds (default: 3)\n" | ||
88 | " -t, --retries=NUM Send up to NUM request packets\n" | ||
89 | " -v, --version Display version\n" | ||
90 | ); | ||
91 | exit(0); | ||
92 | } | ||
93 | #else | ||
94 | #define show_usage bb_show_usage | ||
95 | extern void show_usage(void) ATTRIBUTE_NORETURN; | ||
96 | #endif | ||
97 | |||
98 | |||
99 | /* just a little helper */ | 64 | /* just a little helper */ |
100 | static void change_mode(int new_mode) | 65 | static void change_mode(int new_mode) |
101 | { | 66 | { |
@@ -169,11 +134,7 @@ static void client_background(void) | |||
169 | } | 134 | } |
170 | 135 | ||
171 | 136 | ||
172 | #ifdef COMBINED_BINARY | ||
173 | int udhcpc_main(int argc, char *argv[]) | 137 | int udhcpc_main(int argc, char *argv[]) |
174 | #else | ||
175 | int main(int argc, char *argv[]) | ||
176 | #endif | ||
177 | { | 138 | { |
178 | uint8_t *temp, *message; | 139 | uint8_t *temp, *message; |
179 | unsigned long t1 = 0, t2 = 0, xid = 0; | 140 | unsigned long t1 = 0, t2 = 0, xid = 0; |
@@ -218,7 +179,7 @@ int main(int argc, char *argv[]) | |||
218 | 179 | ||
219 | switch (c) { | 180 | switch (c) { |
220 | case 'c': | 181 | case 'c': |
221 | if (no_clientid) show_usage(); | 182 | if (no_clientid) bb_show_usage(); |
222 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); | 183 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); |
223 | free(client_config.clientid); | 184 | free(client_config.clientid); |
224 | client_config.clientid = xmalloc(len + 2); | 185 | client_config.clientid = xmalloc(len + 2); |
@@ -228,7 +189,7 @@ int main(int argc, char *argv[]) | |||
228 | strncpy((char*)client_config.clientid + OPT_DATA, optarg, len); | 189 | strncpy((char*)client_config.clientid + OPT_DATA, optarg, len); |
229 | break; | 190 | break; |
230 | case 'C': | 191 | case 'C': |
231 | if (client_config.clientid) show_usage(); | 192 | if (client_config.clientid) bb_show_usage(); |
232 | no_clientid = 1; | 193 | no_clientid = 1; |
233 | break; | 194 | break; |
234 | case 'V': | 195 | case 'V': |
@@ -300,7 +261,7 @@ int main(int argc, char *argv[]) | |||
300 | return 0; | 261 | return 0; |
301 | break; | 262 | break; |
302 | default: | 263 | default: |
303 | show_usage(); | 264 | bb_show_usage(); |
304 | } | 265 | } |
305 | } | 266 | } |
306 | 267 | ||
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index cd8252649..0f268afed 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -1974,7 +1974,7 @@ create_sgiinfo(void) | |||
1974 | /* I keep SGI's habit to write the sgilabel to the second block */ | 1974 | /* I keep SGI's habit to write the sgilabel to the second block */ |
1975 | sgilabel->directory[0].vol_file_start = SGI_SSWAP32(2); | 1975 | sgilabel->directory[0].vol_file_start = SGI_SSWAP32(2); |
1976 | sgilabel->directory[0].vol_file_size = SGI_SSWAP32(sizeof(sgiinfo)); | 1976 | sgilabel->directory[0].vol_file_size = SGI_SSWAP32(sizeof(sgiinfo)); |
1977 | strncpy((char*)sgilabel->directory[0].vol_file_name, "sgilabel", 8); | 1977 | strcpy((char*)sgilabel->directory[0].vol_file_name, "sgilabel"); |
1978 | } | 1978 | } |
1979 | 1979 | ||
1980 | static sgiinfo *fill_sgiinfo(void); | 1980 | static sgiinfo *fill_sgiinfo(void); |