diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-08 15:08:42 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-08 15:08:42 +0000 |
commit | 8d9f495d68664017e0b87f2c0c2d0eae9f3c4836 (patch) | |
tree | 157087760d624a657c3ce11b142afb1c72bf225a | |
parent | b04b4357ff5a5b5194a7ff3c875d8746fac9ff33 (diff) | |
download | busybox-w32-8d9f495d68664017e0b87f2c0c2d0eae9f3c4836.tar.gz busybox-w32-8d9f495d68664017e0b87f2c0c2d0eae9f3c4836.tar.bz2 busybox-w32-8d9f495d68664017e0b87f2c0c2d0eae9f3c4836.zip |
getopt32: fix llist_t options ordering. llist_rev is not unused.
function old new delta
tar_main 705 695 -10
sort_main 928 918 -10
decode_format_string 886 876 -10
run_parts_main 197 185 -12
ps_main 513 500 -13
wget_main 2764 2750 -14
awk_main 1014 1000 -14
od_main 2886 2866 -20
llist_rev 25 - -25
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/8 up/down: 0/-128) Total: -128 bytes
-rw-r--r-- | archival/tar.c | 3 | ||||
-rw-r--r-- | coreutils/od_bloaty.c | 1 | ||||
-rw-r--r-- | coreutils/sort.c | 1 | ||||
-rw-r--r-- | debianutils/run_parts.c | 3 | ||||
-rw-r--r-- | editors/awk.c | 1 | ||||
-rw-r--r-- | include/libbb.h | 69 | ||||
-rw-r--r-- | libbb/getopt32.c | 4 | ||||
-rw-r--r-- | libbb/llist.c | 23 | ||||
-rw-r--r-- | networking/wget.c | 2 | ||||
-rw-r--r-- | procps/ps.c | 1 |
10 files changed, 53 insertions, 55 deletions
diff --git a/archival/tar.c b/archival/tar.c index 6552d6c57..f2f1ccd06 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -864,10 +864,9 @@ int tar_main(int argc, char **argv) | |||
864 | char *cp = last_char_is(argv[optind], '/'); | 864 | char *cp = last_char_is(argv[optind], '/'); |
865 | if (cp > argv[optind]) | 865 | if (cp > argv[optind]) |
866 | *cp = '\0'; | 866 | *cp = '\0'; |
867 | llist_add_to(&tar_handle->accept, argv[optind]); | 867 | llist_add_to_end(&tar_handle->accept, argv[optind]); |
868 | optind++; | 868 | optind++; |
869 | } | 869 | } |
870 | tar_handle->accept = llist_rev(tar_handle->accept); | ||
871 | 870 | ||
872 | if (tar_handle->accept || tar_handle->reject) | 871 | if (tar_handle->accept || tar_handle->reject) |
873 | tar_handle->filter = filter_accept_reject_list; | 872 | tar_handle->filter = filter_accept_reject_list; |
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index 74765f842..efdbf354a 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c | |||
@@ -1312,7 +1312,6 @@ int od_main(int argc, char **argv) | |||
1312 | if (opt & OPT_l) decode_format_string("d4"); | 1312 | if (opt & OPT_l) decode_format_string("d4"); |
1313 | if (opt & OPT_o) decode_format_string("o2"); | 1313 | if (opt & OPT_o) decode_format_string("o2"); |
1314 | //if (opt & OPT_t)... | 1314 | //if (opt & OPT_t)... |
1315 | lst_t = llist_rev(lst_t); | ||
1316 | while (lst_t) { | 1315 | while (lst_t) { |
1317 | decode_format_string(lst_t->data); | 1316 | decode_format_string(lst_t->data); |
1318 | lst_t = lst_t->link; | 1317 | lst_t = lst_t->link; |
diff --git a/coreutils/sort.c b/coreutils/sort.c index 311d0cb9c..dad542964 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
@@ -296,7 +296,6 @@ int sort_main(int argc, char **argv) | |||
296 | key_separator = str_t[0]; | 296 | key_separator = str_t[0]; |
297 | } | 297 | } |
298 | /* parse sort key */ | 298 | /* parse sort key */ |
299 | lst_k = llist_rev(lst_k); | ||
300 | while (lst_k) { | 299 | while (lst_k) { |
301 | enum { | 300 | enum { |
302 | FLAG_allowed_for_k = | 301 | FLAG_allowed_for_k = |
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c index 873263a22..eb2fb94b3 100644 --- a/debianutils/run_parts.c +++ b/debianutils/run_parts.c | |||
@@ -131,9 +131,6 @@ int run_parts_main(int argc, char **argv) | |||
131 | */ | 131 | */ |
132 | umask(xstrtoul_range(umask_p, 8, 0, 07777)); | 132 | umask(xstrtoul_range(umask_p, 8, 0, 07777)); |
133 | } | 133 | } |
134 | //XXX: FIXME: reverse the list before handing it over to the user. | ||
135 | //XXX: FIXME: The common case seems to be to use the order given by the user | ||
136 | arg_list = llist_rev(arg_list); /* XXX: getopt32 appends them */ | ||
137 | for (tmp = 1; arg_list; arg_list = arg_list->link, tmp++) | 134 | for (tmp = 1; arg_list; arg_list = arg_list->link, tmp++) |
138 | G.cmd[tmp] = arg_list->data; | 135 | G.cmd[tmp] = arg_list->data; |
139 | /* G.cmd[tmp] = NULL; - G is already zeroed out */ | 136 | /* G.cmd[tmp] = NULL; - G is already zeroed out */ |
diff --git a/editors/awk.c b/editors/awk.c index a18025ef0..f331a33fa 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -2707,7 +2707,6 @@ int awk_main(int argc, char **argv) | |||
2707 | argv += optind; | 2707 | argv += optind; |
2708 | argc -= optind; | 2708 | argc -= optind; |
2709 | if (opt & 0x1) setvar_s(V[FS], opt_F); // -F | 2709 | if (opt & 0x1) setvar_s(V[FS], opt_F); // -F |
2710 | opt_v = llist_rev(opt_v); | ||
2711 | while (opt_v) { /* -v */ | 2710 | while (opt_v) { /* -v */ |
2712 | if (!is_assignment(llist_pop(&opt_v))) | 2711 | if (!is_assignment(llist_pop(&opt_v))) |
2713 | bb_show_usage(); | 2712 | bb_show_usage(); |
diff --git a/include/libbb.h b/include/libbb.h index 6956aaf7b..6731adfe3 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -285,7 +285,7 @@ extern void sig_catch(int,void (*)(int)); | |||
285 | //#define sig_uncatch(s) (sig_catch((s), SIG_DFL)) | 285 | //#define sig_uncatch(s) (sig_catch((s), SIG_DFL)) |
286 | extern void sig_block(int); | 286 | extern void sig_block(int); |
287 | extern void sig_unblock(int); | 287 | extern void sig_unblock(int); |
288 | /* UNUSED: extern void sig_blocknone(void);*/ | 288 | /* UNUSED: extern void sig_blocknone(void); */ |
289 | extern void sig_pause(void); | 289 | extern void sig_pause(void); |
290 | 290 | ||
291 | #define wait_crashed(w) ((w) & 127) | 291 | #define wait_crashed(w) ((w) & 127) |
@@ -294,7 +294,6 @@ extern void sig_pause(void); | |||
294 | #define wait_stopped(w) (((w) & 127) == 127) | 294 | #define wait_stopped(w) (((w) & 127) == 127) |
295 | 295 | ||
296 | 296 | ||
297 | |||
298 | void xsetgid(gid_t gid); | 297 | void xsetgid(gid_t gid); |
299 | void xsetuid(uid_t uid); | 298 | void xsetuid(uid_t uid); |
300 | void xchdir(const char *path); | 299 | void xchdir(const char *path); |
@@ -343,7 +342,7 @@ int xsocket_stream(len_and_sockaddr **lsap); | |||
343 | /* Create server socket bound to bindaddr:port. bindaddr can be NULL, | 342 | /* Create server socket bound to bindaddr:port. bindaddr can be NULL, |
344 | * numeric IP ("N.N.N.N") or numeric IPv6 address, | 343 | * numeric IP ("N.N.N.N") or numeric IPv6 address, |
345 | * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT"). | 344 | * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT"). |
346 | * If there is no suffix, port argument is used */ | 345 | * Only if there is no suffix, port argument is used */ |
347 | int create_and_bind_stream_or_die(const char *bindaddr, int port); | 346 | int create_and_bind_stream_or_die(const char *bindaddr, int port); |
348 | int create_and_bind_dgram_or_die(const char *bindaddr, int port); | 347 | int create_and_bind_dgram_or_die(const char *bindaddr, int port); |
349 | /* Create client TCP socket connected to peer:port. Peer cannot be NULL. | 348 | /* Create client TCP socket connected to peer:port. Peer cannot be NULL. |
@@ -412,9 +411,9 @@ extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, | |||
412 | //int LONE_DASH(const char *s) { return s[0] == '-' && !s[1]; } | 411 | //int LONE_DASH(const char *s) { return s[0] == '-' && !s[1]; } |
413 | //static ATTRIBUTE_ALWAYS_INLINE | 412 | //static ATTRIBUTE_ALWAYS_INLINE |
414 | //int NOT_LONE_DASH(const char *s) { return s[0] != '-' || s[1]; } | 413 | //int NOT_LONE_DASH(const char *s) { return s[0] != '-' || s[1]; } |
415 | #define LONE_DASH(s) ((s)[0] == '-' && !(s)[1]) | 414 | #define LONE_DASH(s) ((s)[0] == '-' && !(s)[1]) |
416 | #define NOT_LONE_DASH(s) ((s)[0] != '-' || (s)[1]) | 415 | #define NOT_LONE_DASH(s) ((s)[0] != '-' || (s)[1]) |
417 | #define LONE_CHAR(s,c) ((s)[0] == (c) && !(s)[1]) | 416 | #define LONE_CHAR(s,c) ((s)[0] == (c) && !(s)[1]) |
418 | #define NOT_LONE_CHAR(s,c) ((s)[0] != (c) || (s)[1]) | 417 | #define NOT_LONE_CHAR(s,c) ((s)[0] != (c) || (s)[1]) |
419 | 418 | ||
420 | /* dmalloc will redefine these to it's own implementation. It is safe | 419 | /* dmalloc will redefine these to it's own implementation. It is safe |
@@ -456,14 +455,17 @@ extern FILE *fopen_or_warn(const char *filename, const char *mode); | |||
456 | extern FILE *fopen_or_warn_stdin(const char *filename); | 455 | extern FILE *fopen_or_warn_stdin(const char *filename); |
457 | 456 | ||
458 | 457 | ||
459 | extern char *utoa(unsigned n); | 458 | char *utoa(unsigned n); |
460 | extern char *itoa(int n); | 459 | char *itoa(int n); |
461 | /* Returns a pointer past the formatted number, does NOT null-terminate */ | 460 | /* Returns a pointer past the formatted number, does NOT null-terminate */ |
462 | extern char *utoa_to_buf(unsigned n, char *buf, unsigned buflen); | 461 | char *utoa_to_buf(unsigned n, char *buf, unsigned buflen); |
463 | extern char *itoa_to_buf(int n, char *buf, unsigned buflen); | 462 | char *itoa_to_buf(int n, char *buf, unsigned buflen); |
464 | extern void smart_ulltoa5(unsigned long long ul, char buf[5]); | 463 | void smart_ulltoa5(unsigned long long ul, char buf[5]); |
465 | /* Put a string of hex bytes (ala "1b"), return advanced pointer */ | 464 | //TODO: provide pointer to buf (avoid statics)? |
466 | extern char *bin2hex(char *buf, const char *cp, int count); | 465 | const char *make_human_readable_str(unsigned long long size, |
466 | unsigned long block_size, unsigned long display_unit); | ||
467 | /* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */ | ||
468 | char *bin2hex(char *buf, const char *cp, int count); | ||
467 | 469 | ||
468 | struct suffix_mult { | 470 | struct suffix_mult { |
469 | const char *suffix; | 471 | const char *suffix; |
@@ -580,16 +582,20 @@ extern uint32_t option_mask32; | |||
580 | extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...); | 582 | extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...); |
581 | 583 | ||
582 | 584 | ||
583 | typedef struct llist_s { | 585 | typedef struct llist_t { |
584 | char *data; | 586 | char *data; |
585 | struct llist_s *link; | 587 | struct llist_t *link; |
586 | } llist_t; | 588 | } llist_t; |
587 | extern void llist_add_to(llist_t **old_head, void *data); | 589 | void llist_add_to(llist_t **old_head, void *data); |
588 | extern void llist_add_to_end(llist_t **list_head, void *data); | 590 | void llist_add_to_end(llist_t **list_head, void *data); |
589 | extern void *llist_pop(llist_t **elm); | 591 | void *llist_pop(llist_t **elm); |
590 | extern void llist_unlink(llist_t **head, llist_t *elm); | 592 | void llist_unlink(llist_t **head, llist_t *elm); |
591 | extern void llist_free(llist_t *elm, void (*freeit)(void *data)); | 593 | void llist_free(llist_t *elm, void (*freeit)(void *data)); |
592 | extern llist_t* llist_rev(llist_t *list); | 594 | llist_t *llist_rev(llist_t *list); |
595 | /* BTW, surprisingly, changing API to | ||
596 | * llist_t *llist_add_to(llist_t *old_head, void *data) | ||
597 | * etc does not result in smaller code... */ | ||
598 | |||
593 | 599 | ||
594 | #if ENABLE_FEATURE_PIDFILE | 600 | #if ENABLE_FEATURE_PIDFILE |
595 | int write_pidfile(const char *path); | 601 | int write_pidfile(const char *path); |
@@ -674,10 +680,6 @@ extern int del_loop(const char *device); | |||
674 | extern int set_loop(char **device, const char *file, unsigned long long offset); | 680 | extern int set_loop(char **device, const char *file, unsigned long long offset); |
675 | 681 | ||
676 | 682 | ||
677 | //TODO: provide pointer to buf (avoid statics)? | ||
678 | const char *make_human_readable_str(unsigned long long size, | ||
679 | unsigned long block_size, unsigned long display_unit); | ||
680 | |||
681 | //TODO: pass buf pointer or return allocated buf (avoid statics)? | 683 | //TODO: pass buf pointer or return allocated buf (avoid statics)? |
682 | char *bb_askpass(int timeout, const char * prompt); | 684 | char *bb_askpass(int timeout, const char * prompt); |
683 | int bb_ask_confirmation(void); | 685 | int bb_ask_confirmation(void); |
@@ -725,14 +727,14 @@ extern void print_login_issue(const char *issue_file, const char *tty); | |||
725 | extern void print_login_prompt(void); | 727 | extern void print_login_prompt(void); |
726 | 728 | ||
727 | 729 | ||
728 | extern int get_terminal_width_height(const int fd, int *width, int *height); | 730 | int get_terminal_width_height(const int fd, int *width, int *height); |
729 | 731 | ||
730 | char *is_in_ino_dev_hashtable(const struct stat *statbuf); | 732 | char *is_in_ino_dev_hashtable(const struct stat *statbuf); |
731 | void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); | 733 | void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); |
732 | void reset_ino_dev_hashtable(void); | 734 | void reset_ino_dev_hashtable(void); |
733 | #ifdef __GLIBC__ | 735 | #ifdef __GLIBC__ |
734 | /* At least glibc has horrendously large inline for this, so wrap it */ | 736 | /* At least glibc has horrendously large inline for this, so wrap it */ |
735 | extern unsigned long long bb_makedev(unsigned int major, unsigned int minor); | 737 | unsigned long long bb_makedev(unsigned int major, unsigned int minor); |
736 | #undef makedev | 738 | #undef makedev |
737 | #define makedev(a,b) bb_makedev(a,b) | 739 | #define makedev(a,b) bb_makedev(a,b) |
738 | #endif | 740 | #endif |
@@ -745,7 +747,7 @@ extern unsigned long long bb_makedev(unsigned int major, unsigned int minor); | |||
745 | #else | 747 | #else |
746 | #define MAX_HISTORY 0 | 748 | #define MAX_HISTORY 0 |
747 | #endif | 749 | #endif |
748 | struct line_input_t { | 750 | typedef struct line_input_t { |
749 | int flags; | 751 | int flags; |
750 | const char *path_lookup; | 752 | const char *path_lookup; |
751 | #if MAX_HISTORY | 753 | #if MAX_HISTORY |
@@ -754,7 +756,7 @@ struct line_input_t { | |||
754 | USE_FEATURE_EDITING_SAVEHISTORY(const char *hist_file;) | 756 | USE_FEATURE_EDITING_SAVEHISTORY(const char *hist_file;) |
755 | char *history[MAX_HISTORY + 1]; | 757 | char *history[MAX_HISTORY + 1]; |
756 | #endif | 758 | #endif |
757 | }; | 759 | } line_input_t; |
758 | enum { | 760 | enum { |
759 | DO_HISTORY = 1 * (MAX_HISTORY > 0), | 761 | DO_HISTORY = 1 * (MAX_HISTORY > 0), |
760 | SAVE_HISTORY = 2 * (MAX_HISTORY > 0) * ENABLE_FEATURE_EDITING_SAVEHISTORY, | 762 | SAVE_HISTORY = 2 * (MAX_HISTORY > 0) * ENABLE_FEATURE_EDITING_SAVEHISTORY, |
@@ -764,7 +766,6 @@ enum { | |||
764 | WITH_PATH_LOOKUP = 0x20, | 766 | WITH_PATH_LOOKUP = 0x20, |
765 | FOR_SHELL = DO_HISTORY | SAVE_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION, | 767 | FOR_SHELL = DO_HISTORY | SAVE_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION, |
766 | }; | 768 | }; |
767 | typedef struct line_input_t line_input_t; | ||
768 | line_input_t *new_line_input_t(int flags); | 769 | line_input_t *new_line_input_t(int flags); |
769 | int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *state); | 770 | int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *state); |
770 | #else | 771 | #else |
@@ -798,7 +799,7 @@ typedef struct { | |||
798 | /* sizeof(task_struct.comm) in /usr/include/linux/sched.h */ | 799 | /* sizeof(task_struct.comm) in /usr/include/linux/sched.h */ |
799 | char state[4]; | 800 | char state[4]; |
800 | char comm[COMM_LEN]; | 801 | char comm[COMM_LEN]; |
801 | // user/group? - use passwd/group parsing functions | 802 | /* user/group? - use passwd/group parsing functions */ |
802 | } procps_status_t; | 803 | } procps_status_t; |
803 | enum { | 804 | enum { |
804 | PSSCAN_PID = 1 << 0, | 805 | PSSCAN_PID = 1 << 0, |
@@ -902,18 +903,22 @@ extern const char bb_dev_null[]; | |||
902 | extern const int const_int_0; | 903 | extern const int const_int_0; |
903 | extern const int const_int_1; | 904 | extern const int const_int_1; |
904 | 905 | ||
906 | |||
905 | #ifndef BUFSIZ | 907 | #ifndef BUFSIZ |
906 | #define BUFSIZ 4096 | 908 | #define BUFSIZ 4096 |
907 | #endif | 909 | #endif |
910 | // TODO: provide hard guarantees on minimum size of bb_common_bufsiz1 | ||
908 | extern char bb_common_bufsiz1[BUFSIZ+1]; | 911 | extern char bb_common_bufsiz1[BUFSIZ+1]; |
909 | /* This struct is deliberately not defined. */ | 912 | /* This struct is deliberately not defined. */ |
910 | /* See docs/keep_data_small.txt */ | 913 | /* See docs/keep_data_small.txt */ |
911 | struct globals; | 914 | struct globals; |
912 | /* Magic prevents this from going into rodata */ | 915 | /* '*const' ptr makes gcc optimize code much better. |
913 | /* If you want to assign a value, use PTR_TO_GLOBALS = xxx */ | 916 | * Magic prevents ptr_to_globals from going into rodata |
917 | * If you want to assign a value, use PTR_TO_GLOBALS = xxx */ | ||
914 | extern struct globals *const ptr_to_globals; | 918 | extern struct globals *const ptr_to_globals; |
915 | #define PTR_TO_GLOBALS (*(struct globals**)&ptr_to_globals) | 919 | #define PTR_TO_GLOBALS (*(struct globals**)&ptr_to_globals) |
916 | 920 | ||
921 | |||
917 | /* You can change LIBBB_DEFAULT_LOGIN_SHELL, but don't use it, | 922 | /* You can change LIBBB_DEFAULT_LOGIN_SHELL, but don't use it, |
918 | * use bb_default_login_shell and following defines. | 923 | * use bb_default_login_shell and following defines. |
919 | * If you change LIBBB_DEFAULT_LOGIN_SHELL, | 924 | * If you change LIBBB_DEFAULT_LOGIN_SHELL, |
diff --git a/libbb/getopt32.c b/libbb/getopt32.c index 6cdbfd35d..dec97d743 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c | |||
@@ -242,7 +242,7 @@ Special characters: | |||
242 | llist_t *patterns = NULL; | 242 | llist_t *patterns = NULL; |
243 | 243 | ||
244 | (this pointer must be initializated to NULL if the list is empty | 244 | (this pointer must be initializated to NULL if the list is empty |
245 | as required by *llist_add_to(llist_t *old_head, char *new_item).) | 245 | as required by llist_add_to_end(llist_t **old_head, char *new_item).) |
246 | 246 | ||
247 | opt_complementary = "e::"; | 247 | opt_complementary = "e::"; |
248 | 248 | ||
@@ -487,7 +487,7 @@ getopt32(int argc, char **argv, const char *applet_opts, ...) | |||
487 | if (on_off->counter) | 487 | if (on_off->counter) |
488 | (*(on_off->counter))++; | 488 | (*(on_off->counter))++; |
489 | if (on_off->list_flg) { | 489 | if (on_off->list_flg) { |
490 | llist_add_to((llist_t **)(on_off->optarg), optarg); | 490 | llist_add_to_end((llist_t **)(on_off->optarg), optarg); |
491 | } else if (on_off->optarg) { | 491 | } else if (on_off->optarg) { |
492 | *(char **)(on_off->optarg) = optarg; | 492 | *(char **)(on_off->optarg) = optarg; |
493 | } | 493 | } |
diff --git a/libbb/llist.c b/libbb/llist.c index 2b34f762c..706751447 100644 --- a/libbb/llist.c +++ b/libbb/llist.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include "libbb.h" | 14 | #include "libbb.h" |
15 | 15 | ||
16 | /* Add data to the start of the linked list. */ | 16 | /* Add data to the start of the linked list. */ |
17 | void llist_add_to(llist_t ** old_head, void *data) | 17 | void llist_add_to(llist_t **old_head, void *data) |
18 | { | 18 | { |
19 | llist_t *new_head = xmalloc(sizeof(llist_t)); | 19 | llist_t *new_head = xmalloc(sizeof(llist_t)); |
20 | 20 | ||
@@ -24,7 +24,7 @@ void llist_add_to(llist_t ** old_head, void *data) | |||
24 | } | 24 | } |
25 | 25 | ||
26 | /* Add data to the end of the linked list. */ | 26 | /* Add data to the end of the linked list. */ |
27 | void llist_add_to_end(llist_t ** list_head, void *data) | 27 | void llist_add_to_end(llist_t **list_head, void *data) |
28 | { | 28 | { |
29 | llist_t *new_item = xmalloc(sizeof(llist_t)); | 29 | llist_t *new_item = xmalloc(sizeof(llist_t)); |
30 | 30 | ||
@@ -43,7 +43,7 @@ void llist_add_to_end(llist_t ** list_head, void *data) | |||
43 | } | 43 | } |
44 | 44 | ||
45 | /* Remove first element from the list and return it */ | 45 | /* Remove first element from the list and return it */ |
46 | void *llist_pop(llist_t ** head) | 46 | void *llist_pop(llist_t **head) |
47 | { | 47 | { |
48 | void *data, *next; | 48 | void *data, *next; |
49 | 49 | ||
@@ -81,7 +81,7 @@ void llist_unlink(llist_t **head, llist_t *elm) | |||
81 | 81 | ||
82 | /* Recursively free all elements in the linked list. If freeit != NULL | 82 | /* Recursively free all elements in the linked list. If freeit != NULL |
83 | * call it on each datum in the list */ | 83 | * call it on each datum in the list */ |
84 | void llist_free(llist_t * elm, void (*freeit) (void *data)) | 84 | void llist_free(llist_t *elm, void (*freeit) (void *data)) |
85 | { | 85 | { |
86 | while (elm) { | 86 | while (elm) { |
87 | void *data = llist_pop(&elm); | 87 | void *data = llist_pop(&elm); |
@@ -91,18 +91,19 @@ void llist_free(llist_t * elm, void (*freeit) (void *data)) | |||
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | /* Reverse list order. Useful since getopt32 saves option params | 94 | #ifdef UNUSED |
95 | * in reverse order */ | 95 | /* Reverse list order. */ |
96 | llist_t *llist_rev(llist_t * list) | 96 | llist_t *llist_rev(llist_t *list) |
97 | { | 97 | { |
98 | llist_t *new = NULL; | 98 | llist_t *rev = NULL; |
99 | 99 | ||
100 | while (list) { | 100 | while (list) { |
101 | llist_t *next = list->link; | 101 | llist_t *next = list->link; |
102 | 102 | ||
103 | list->link = new; | 103 | list->link = rev; |
104 | new = list; | 104 | rev = list; |
105 | list = next; | 105 | list = next; |
106 | } | 106 | } |
107 | return new; | 107 | return rev; |
108 | } | 108 | } |
109 | #endif | ||
diff --git a/networking/wget.c b/networking/wget.c index 94b9b6954..1da18ff77 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -159,7 +159,7 @@ int wget_main(int argc, char **argv) | |||
159 | if (headers_llist) { | 159 | if (headers_llist) { |
160 | int size = 1; | 160 | int size = 1; |
161 | char *cp; | 161 | char *cp; |
162 | llist_t *ll = headers_llist = llist_rev(headers_llist); | 162 | llist_t *ll = headers_llist; |
163 | while (ll) { | 163 | while (ll) { |
164 | size += strlen(ll->data) + 2; | 164 | size += strlen(ll->data) + 2; |
165 | ll = ll->link; | 165 | ll = ll->link; |
diff --git a/procps/ps.c b/procps/ps.c index 2be0b3605..f8f5c1aa9 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -253,7 +253,6 @@ int ps_main(int argc, char **argv) | |||
253 | opt_complementary = "o::"; | 253 | opt_complementary = "o::"; |
254 | getopt32(argc, argv, "o:aAdefl", &opt_o); | 254 | getopt32(argc, argv, "o:aAdefl", &opt_o); |
255 | if (opt_o) { | 255 | if (opt_o) { |
256 | opt_o = llist_rev(opt_o); | ||
257 | do { | 256 | do { |
258 | parse_o(opt_o->data); | 257 | parse_o(opt_o->data); |
259 | opt_o = opt_o->link; | 258 | opt_o = opt_o->link; |