aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-05-26 23:44:51 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-05-26 23:44:51 +0000
commitab1c37300f2a6a0215c17cd683df316d8a1e8f59 (patch)
treeb717c772c6fef53c34b723341a8c5b12ccb57902
parentc806c321575528e76c4479666d398a0534cb81d8 (diff)
downloadbusybox-w32-ab1c37300f2a6a0215c17cd683df316d8a1e8f59.tar.gz
busybox-w32-ab1c37300f2a6a0215c17cd683df316d8a1e8f59.tar.bz2
busybox-w32-ab1c37300f2a6a0215c17cd683df316d8a1e8f59.zip
Change llist_add_* to take the address of the list rather than returning the new
head, and change all the callers. git-svn-id: svn://busybox.net/trunk/busybox@15199 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--archival/ar.c2
-rw-r--r--archival/cpio.c2
-rw-r--r--archival/dpkg.c12
-rw-r--r--archival/dpkg_deb.c10
-rw-r--r--archival/libunarchive/get_header_tar.c2
-rw-r--r--archival/libunarchive/init_handle.c3
-rw-r--r--archival/tar.c4
-rw-r--r--archival/unzip.c4
-rw-r--r--editors/sed.c2
-rw-r--r--findutils/grep.c4
-rw-r--r--include/libbb.h4
-rw-r--r--libbb/getopt_ulflags.c3
-rw-r--r--libbb/llist.c28
-rw-r--r--networking/ifupdown.c10
-rw-r--r--procps/pidof.c7
-rw-r--r--util-linux/mount.c2
16 files changed, 42 insertions, 57 deletions
diff --git a/archival/ar.c b/archival/ar.c
index 7782af89f..f9a6bb79f 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -97,7 +97,7 @@ int ar_main(int argc, char **argv)
97 97
98 while (optind < argc) { 98 while (optind < argc) {
99 archive_handle->filter = filter_accept_list; 99 archive_handle->filter = filter_accept_list;
100 archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind++]); 100 llist_add_to(&(archive_handle->accept), argv[optind++]);
101 } 101 }
102 102
103 archive_xread_all(archive_handle, magic, 7); 103 archive_xread_all(archive_handle, magic, 7);
diff --git a/archival/cpio.c b/archival/cpio.c
index 26f845bc9..478379c54 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -88,7 +88,7 @@ int cpio_main(int argc, char **argv)
88 88
89 while (optind < argc) { 89 while (optind < argc) {
90 archive_handle->filter = filter_accept_list; 90 archive_handle->filter = filter_accept_list;
91 archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]); 91 llist_add_to(&(archive_handle->accept), argv[optind]);
92 optind++; 92 optind++;
93 } 93 }
94 94
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 3621db41d..2895f4f38 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -1484,10 +1484,10 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
1484 1484
1485 /* We don't care about data.tar.* or debian-binary, just control.tar.* */ 1485 /* We don't care about data.tar.* or debian-binary, just control.tar.* */
1486#ifdef CONFIG_FEATURE_DEB_TAR_GZ 1486#ifdef CONFIG_FEATURE_DEB_TAR_GZ
1487 ar_handle->accept = llist_add_to(NULL, "control.tar.gz"); 1487 llist_add_to(&(ar_handle->accept), "control.tar.gz");
1488#endif 1488#endif
1489#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 1489#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
1490 ar_handle->accept = llist_add_to(ar_handle->accept, "control.tar.bz2"); 1490 llist_add_to(&(ar_handle->accept), "control.tar.bz2");
1491#endif 1491#endif
1492 1492
1493 /* Assign the tar handle as a subarchive of the ar handle */ 1493 /* Assign the tar handle as a subarchive of the ar handle */
@@ -1506,10 +1506,10 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
1506 1506
1507 /* We don't care about control.tar.* or debian-binary, just data.tar.* */ 1507 /* We don't care about control.tar.* or debian-binary, just data.tar.* */
1508#ifdef CONFIG_FEATURE_DEB_TAR_GZ 1508#ifdef CONFIG_FEATURE_DEB_TAR_GZ
1509 ar_handle->accept = llist_add_to(NULL, "data.tar.gz"); 1509 llist_add_to(&(ar_handle->accept), "data.tar.gz");
1510#endif 1510#endif
1511#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 1511#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
1512 ar_handle->accept = llist_add_to(ar_handle->accept, "data.tar.bz2"); 1512 llist_add_to(&(ar_handle->accept), "data.tar.bz2");
1513#endif 1513#endif
1514 1514
1515 /* Assign the tar handle as a subarchive of the ar handle */ 1515 /* Assign the tar handle as a subarchive of the ar handle */
@@ -1575,7 +1575,7 @@ static void unpack_package(deb_file_t *deb_file)
1575 while(all_control_files[i]) { 1575 while(all_control_files[i]) {
1576 char *c = (char *) xmalloc(3 + strlen(all_control_files[i])); 1576 char *c = (char *) xmalloc(3 + strlen(all_control_files[i]));
1577 sprintf(c, "./%s", all_control_files[i]); 1577 sprintf(c, "./%s", all_control_files[i]);
1578 accept_list= llist_add_to(accept_list, c); 1578 llist_add_to(&accept_list, c);
1579 i++; 1579 i++;
1580 } 1580 }
1581 archive_handle->sub_archive->accept = accept_list; 1581 archive_handle->sub_archive->accept = accept_list;
@@ -1705,7 +1705,7 @@ int dpkg_main(int argc, char **argv)
1705 llist_t *control_list = NULL; 1705 llist_t *control_list = NULL;
1706 1706
1707 /* Extract the control file */ 1707 /* Extract the control file */
1708 control_list = llist_add_to(NULL, "./control"); 1708 llist_add_to(&control_list, "./control");
1709 archive_handle = init_archive_deb_ar(argv[optind]); 1709 archive_handle = init_archive_deb_ar(argv[optind]);
1710 init_archive_deb_control(archive_handle); 1710 init_archive_deb_control(archive_handle);
1711 deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list); 1711 deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index fc8b9221d..b99f227fc 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -36,13 +36,13 @@ int dpkg_deb_main(int argc, char **argv)
36 ar_archive->filter = filter_accept_list_reassign; 36 ar_archive->filter = filter_accept_list_reassign;
37 37
38#ifdef CONFIG_FEATURE_DEB_TAR_GZ 38#ifdef CONFIG_FEATURE_DEB_TAR_GZ
39 ar_archive->accept = llist_add_to(NULL, "data.tar.gz"); 39 llist_add_to(&(ar_archive->accept), "data.tar.gz");
40 control_tar_llist = llist_add_to(NULL, "control.tar.gz"); 40 llist_add_to(&control_tar_llist, "control.tar.gz");
41#endif 41#endif
42 42
43#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 43#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
44 ar_archive->accept = llist_add_to(ar_archive->accept, "data.tar.bz2"); 44 llist_add_to(&(ar_archive->accept), "data.tar.bz2");
45 control_tar_llist = llist_add_to(control_tar_llist, "control.tar.bz2"); 45 llist_add_to(&control_tar_llist, "control.tar.bz2");
46#endif 46#endif
47 47
48 bb_opt_complementally = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX"; 48 bb_opt_complementally = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
@@ -65,7 +65,7 @@ int dpkg_deb_main(int argc, char **argv)
65 * it should accept a second argument which specifies a 65 * it should accept a second argument which specifies a
66 * specific field to print */ 66 * specific field to print */
67 ar_archive->accept = control_tar_llist; 67 ar_archive->accept = control_tar_llist;
68 tar_archive->accept = llist_add_to(NULL, "./control"); 68 llist_add_to(&(tar_archive->accept), "./control");
69 tar_archive->filter = filter_accept_list; 69 tar_archive->filter = filter_accept_list;
70 tar_archive->action_data = data_extract_to_stdout; 70 tar_archive->action_data = data_extract_to_stdout;
71 } 71 }
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index cd38f4560..c9308f906 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -206,7 +206,7 @@ char get_header_tar(archive_handle_t *archive_handle)
206 archive_handle->action_header(archive_handle->file_header); 206 archive_handle->action_header(archive_handle->file_header);
207 archive_handle->flags |= ARCHIVE_EXTRACT_QUIET; 207 archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
208 archive_handle->action_data(archive_handle); 208 archive_handle->action_data(archive_handle);
209 archive_handle->passed = llist_add_to(archive_handle->passed, file_header->name); 209 llist_add_to(&(archive_handle->passed), file_header->name);
210 } else { 210 } else {
211 data_skip(archive_handle); 211 data_skip(archive_handle);
212 } 212 }
diff --git a/archival/libunarchive/init_handle.c b/archival/libunarchive/init_handle.c
index 3cee84f67..1813131de 100644
--- a/archival/libunarchive/init_handle.c
+++ b/archival/libunarchive/init_handle.c
@@ -24,8 +24,7 @@ archive_handle_t *init_handle(void)
24 archive_handle_t *archive_handle; 24 archive_handle_t *archive_handle;
25 25
26 /* Initialise default values */ 26 /* Initialise default values */
27 archive_handle = xmalloc(sizeof(archive_handle_t)); 27 archive_handle = xzalloc(sizeof(archive_handle_t));
28 memset(archive_handle, 0, sizeof(archive_handle_t));
29 archive_handle->file_header = xmalloc(sizeof(file_header_t)); 28 archive_handle->file_header = xmalloc(sizeof(file_header_t));
30 archive_handle->action_header = header_skip; 29 archive_handle->action_header = header_skip;
31 archive_handle->action_data = data_skip; 30 archive_handle->action_data = data_skip;
diff --git a/archival/tar.c b/archival/tar.c
index e4008b0c9..f3594f685 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -551,7 +551,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
551 cur = cur->link; 551 cur = cur->link;
552 free(tmp); 552 free(tmp);
553 while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) 553 while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL)
554 newlist = llist_add_to(newlist, line); 554 llist_add_to(&newlist, line);
555 fclose(src_stream); 555 fclose(src_stream);
556 } 556 }
557 return newlist; 557 return newlist;
@@ -800,7 +800,7 @@ int tar_main(int argc, char **argv)
800 if (filename_ptr > argv[optind]) 800 if (filename_ptr > argv[optind])
801 *filename_ptr = '\0'; 801 *filename_ptr = '\0';
802 802
803 tar_handle->accept = llist_add_to(tar_handle->accept, argv[optind]); 803 llist_add_to(&(tar_handle->accept), argv[optind]);
804 optind++; 804 optind++;
805 } 805 }
806 806
diff --git a/archival/unzip.c b/archival/unzip.c
index 2cb256c76..0b1e6f997 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -180,7 +180,7 @@ int unzip_main(int argc, char **argv)
180 180
181 case 1: /* Include files */ 181 case 1: /* Include files */
182 if (opt == 1) { 182 if (opt == 1) {
183 zaccept = llist_add_to(zaccept, optarg); 183 llist_add_to(&zaccept, optarg);
184 184
185 } else if (opt == 'd') { 185 } else if (opt == 'd') {
186 base_dir = optarg; 186 base_dir = optarg;
@@ -196,7 +196,7 @@ int unzip_main(int argc, char **argv)
196 196
197 case 2 : /* Exclude files */ 197 case 2 : /* Exclude files */
198 if (opt == 1) { 198 if (opt == 1) {
199 zreject = llist_add_to(zreject, optarg); 199 llist_add_to(&zreject, optarg);
200 200
201 } else if (opt == 'd') { /* Extract to base directory */ 201 } else if (opt == 'd') { /* Extract to base directory */
202 base_dir = optarg; 202 base_dir = optarg;
diff --git a/editors/sed.c b/editors/sed.c
index a17d1e551..6585a60bd 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -683,7 +683,7 @@ static sed_cmd_t *branch_to(const char *label)
683 683
684static void append(char *s) 684static void append(char *s)
685{ 685{
686 bbg.append_head = llist_add_to_end(bbg.append_head, bb_xstrdup(s)); 686 llist_add_to_end(&bbg.append_head, bb_xstrdup(s));
687} 687}
688 688
689static void flush_append(void) 689static void flush_append(void)
diff --git a/findutils/grep.c b/findutils/grep.c
index e5b5e3242..fac296941 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -273,7 +273,7 @@ static void load_regexes_from_file(llist_t *fopt)
273 free(cur); 273 free(cur);
274 f = bb_xfopen(ffile, "r"); 274 f = bb_xfopen(ffile, "r");
275 while ((line = bb_get_chomped_line_from_file(f)) != NULL) { 275 while ((line = bb_get_chomped_line_from_file(f)) != NULL) {
276 pattern_head = llist_add_to(pattern_head, 276 llist_add_to(&pattern_head,
277 new_grep_list_data(line, PATTERN_MEM_A)); 277 new_grep_list_data(line, PATTERN_MEM_A));
278 } 278 }
279 } 279 }
@@ -373,7 +373,7 @@ int grep_main(int argc, char **argv)
373 else { 373 else {
374 char *pattern = new_grep_list_data(*argv++, 0); 374 char *pattern = new_grep_list_data(*argv++, 0);
375 375
376 pattern_head = llist_add_to(pattern_head, pattern); 376 llist_add_to(&pattern_head, pattern);
377 argc--; 377 argc--;
378 } 378 }
379 } 379 }
diff --git a/include/libbb.h b/include/libbb.h
index 93b29c6ae..3bb663bb5 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -84,8 +84,8 @@ typedef struct llist_s {
84 char *data; 84 char *data;
85 struct llist_s *link; 85 struct llist_s *link;
86} llist_t; 86} llist_t;
87extern llist_t *llist_add_to(llist_t *old_head, void *data); 87extern void llist_add_to(llist_t **old_head, void *data);
88extern llist_t *llist_add_to_end(llist_t *list_head, void *data); 88extern void llist_add_to_end(llist_t **list_head, void *data);
89extern void *llist_pop(llist_t **elm); 89extern void *llist_pop(llist_t **elm);
90extern void llist_free(llist_t *elm, void (*freeit)(void *data)); 90extern void llist_free(llist_t *elm, void (*freeit)(void *data));
91 91
diff --git a/libbb/getopt_ulflags.c b/libbb/getopt_ulflags.c
index 76bdeed75..dc40095ee 100644
--- a/libbb/getopt_ulflags.c
+++ b/libbb/getopt_ulflags.c
@@ -474,8 +474,7 @@ loop_arg_is_opt:
474 if(on_off->counter) 474 if(on_off->counter)
475 (*(on_off->counter))++; 475 (*(on_off->counter))++;
476 if(on_off->list_flg) { 476 if(on_off->list_flg) {
477 *(llist_t **)(on_off->optarg) = 477 llist_add_to((llist_t **)(on_off->optarg), optarg);
478 llist_add_to(*(llist_t **)(on_off->optarg), optarg);
479 } else if (on_off->optarg) { 478 } else if (on_off->optarg) {
480 *(char **)(on_off->optarg) = optarg; 479 *(char **)(on_off->optarg) = optarg;
481 } 480 }
diff --git a/libbb/llist.c b/libbb/llist.c
index dd80436c6..fde25e8b7 100644
--- a/libbb/llist.c
+++ b/libbb/llist.c
@@ -14,37 +14,29 @@
14 14
15#ifdef L_llist_add_to 15#ifdef L_llist_add_to
16/* Add data to the start of the linked list. */ 16/* Add data to the start of the linked list. */
17llist_t *llist_add_to(llist_t *old_head, void *data) 17void llist_add_to(llist_t **old_head, void *data)
18{ 18{
19 llist_t *new_head; 19 llist_t *new_head = xmalloc(sizeof(llist_t));
20
21 new_head = xmalloc(sizeof(llist_t));
22 new_head->data = data; 20 new_head->data = data;
23 new_head->link = old_head; 21 new_head->link = *old_head;
24 22 *old_head = new_head;
25 return (new_head);
26} 23}
27#endif 24#endif
28 25
29#ifdef L_llist_add_to_end 26#ifdef L_llist_add_to_end
30/* Add data to the end of the linked list. */ 27/* Add data to the end of the linked list. */
31llist_t *llist_add_to_end(llist_t *list_head, void *data) 28void llist_add_to_end(llist_t **list_head, void *data)
32{ 29{
33 llist_t *new_item; 30 llist_t *new_item = xmalloc(sizeof(llist_t));
34
35 new_item = xmalloc(sizeof(llist_t));
36 new_item->data = data; 31 new_item->data = data;
37 new_item->link = NULL; 32 new_item->link = NULL;
38 33
39 if (list_head == NULL) { 34 if (!*list_head) *list_head = new_item;
40 list_head = new_item; 35 else {
41 } else { 36 llist_t *tail = *list_head;
42 llist_t *tail = list_head; 37 while (tail->link) tail = tail->link;
43 while (tail->link)
44 tail = tail->link;
45 tail->link = new_item; 38 tail->link = new_item;
46 } 39 }
47 return list_head;
48} 40}
49#endif 41#endif
50 42
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 32b92fb62..038bb13bc 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -739,7 +739,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
739 } 739 }
740 } 740 }
741 741
742 defn->ifaces = llist_add_to_end(defn->ifaces, (char*)currif); 742 llist_add_to_end(&(defn->ifaces), (char*)currif);
743 } 743 }
744 debug_noise("iface %s %s %s\n", currif->iface, address_family_name, method_name); 744 debug_noise("iface %s %s %s\n", currif->iface, address_family_name, method_name);
745 } 745 }
@@ -753,7 +753,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
753 } 753 }
754 754
755 /* Add the interface to the list */ 755 /* Add the interface to the list */
756 defn->autointerfaces = llist_add_to_end(defn->autointerfaces, bb_xstrdup(firstword)); 756 llist_add_to_end(&(defn->autointerfaces), bb_xstrdup(firstword));
757 debug_noise("\nauto %s\n", firstword); 757 debug_noise("\nauto %s\n", firstword);
758 } 758 }
759 currently_processing = NONE; 759 currently_processing = NONE;
@@ -1202,14 +1202,14 @@ int ifupdown_main(int argc, char **argv)
1202 /* iface_down */ 1202 /* iface_down */
1203 const llist_t *list = state_list; 1203 const llist_t *list = state_list;
1204 while (list) { 1204 while (list) {
1205 target_list = llist_add_to_end(target_list, bb_xstrdup(list->data)); 1205 llist_add_to_end(&target_list, bb_xstrdup(list->data));
1206 list = list->link; 1206 list = list->link;
1207 } 1207 }
1208 target_list = defn->autointerfaces; 1208 target_list = defn->autointerfaces;
1209#endif 1209#endif
1210 } 1210 }
1211 } else { 1211 } else {
1212 target_list = llist_add_to_end(target_list, argv[optind]); 1212 llist_add_to_end(&target_list, argv[optind]);
1213 } 1213 }
1214 1214
1215 1215
@@ -1311,7 +1311,7 @@ int ifupdown_main(int argc, char **argv)
1311 char *newiface = xmalloc(strlen(iface) + 1 + strlen(liface) + 1); 1311 char *newiface = xmalloc(strlen(iface) + 1 + strlen(liface) + 1);
1312 sprintf(newiface, "%s=%s", iface, liface); 1312 sprintf(newiface, "%s=%s", iface, liface);
1313 if (iface_state == NULL) { 1313 if (iface_state == NULL) {
1314 state_list = llist_add_to_end(state_list, newiface); 1314 llist_add_to_end(&state_list, newiface);
1315 } else { 1315 } else {
1316 free(iface_state->data); 1316 free(iface_state->data);
1317 iface_state->data = newiface; 1317 iface_state->data = newiface;
diff --git a/procps/pidof.c b/procps/pidof.c
index 98008aaf1..4ad6b1567 100644
--- a/procps/pidof.c
+++ b/procps/pidof.c
@@ -67,12 +67,7 @@ int pidof_main(int argc, char **argv)
67 if (!strncmp(omits_p->data, "%PPID", 5)) { 67 if (!strncmp(omits_p->data, "%PPID", 5)) {
68 llist_pop(&omits_p); 68 llist_pop(&omits_p);
69 snprintf(getppid_str, sizeof(getppid_str), "%d", getppid()); 69 snprintf(getppid_str, sizeof(getppid_str), "%d", getppid());
70 omits_p = llist_add_to(omits_p, getppid_str); 70 llist_add_to(&omits_p, getppid_str);
71#if 0
72 } else {
73 bb_error_msg_and_die("illegal omit pid value (%s)!\n",
74 omits_p->data);
75#endif
76 } 71 }
77 omits_p = omits_p->link; 72 omits_p = omits_p->link;
78 } 73 }
diff --git a/util-linux/mount.c b/util-linux/mount.c
index a191f3260..e1c1c601b 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -169,7 +169,7 @@ static llist_t *get_block_backed_filesystems(void)
169 if(*fs=='#' || *fs=='*') continue; 169 if(*fs=='#' || *fs=='*') continue;
170 if(!*fs) continue; 170 if(!*fs) continue;
171 171
172 list=llist_add_to_end(list,bb_xstrdup(fs)); 172 llist_add_to_end(&list,bb_xstrdup(fs));
173 } 173 }
174 if (ENABLE_FEATURE_CLEAN_UP) fclose(f); 174 if (ENABLE_FEATURE_CLEAN_UP) fclose(f);
175 } 175 }