summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 7782af8..f9a6bb7 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -97,7 +97,7 @@ int ar_main(int argc, char **argv)
while (optind < argc) {
archive_handle->filter = filter_accept_list;
- archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind++]);
+ llist_add_to(&(archive_handle->accept), argv[optind++]);
}
archive_xread_all(archive_handle, magic, 7);
diff --git a/archival/cpio.c b/archival/cpio.c
index 26f845b..478379c 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -88,7 +88,7 @@ int cpio_main(int argc, char **argv)
while (optind < argc) {
archive_handle->filter = filter_accept_list;
- archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
+ llist_add_to(&(archive_handle->accept), argv[optind]);
optind++;
}
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 3621db4..2895f4f 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -1484,10 +1484,10 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
/* We don't care about data.tar.* or debian-binary, just control.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
- ar_handle->accept = llist_add_to(NULL, "control.tar.gz");
+ llist_add_to(&(ar_handle->accept), "control.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
- ar_handle->accept = llist_add_to(ar_handle->accept, "control.tar.bz2");
+ llist_add_to(&(ar_handle->accept), "control.tar.bz2");
#endif
/* 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)
/* We don't care about control.tar.* or debian-binary, just data.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
- ar_handle->accept = llist_add_to(NULL, "data.tar.gz");
+ llist_add_to(&(ar_handle->accept), "data.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
- ar_handle->accept = llist_add_to(ar_handle->accept, "data.tar.bz2");
+ llist_add_to(&(ar_handle->accept), "data.tar.bz2");
#endif
/* Assign the tar handle as a subarchive of the ar handle */
@@ -1575,7 +1575,7 @@ static void unpack_package(deb_file_t *deb_file)
while(all_control_files[i]) {
char *c = (char *) xmalloc(3 + strlen(all_control_files[i]));
sprintf(c, "./%s", all_control_files[i]);
- accept_list= llist_add_to(accept_list, c);
+ llist_add_to(&accept_list, c);
i++;
}
archive_handle->sub_archive->accept = accept_list;
@@ -1705,7 +1705,7 @@ int dpkg_main(int argc, char **argv)
llist_t *control_list = NULL;
/* Extract the control file */
- control_list = llist_add_to(NULL, "./control");
+ llist_add_to(&control_list, "./control");
archive_handle = init_archive_deb_ar(argv[optind]);
init_archive_deb_control(archive_handle);
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 fc8b922..b99f227 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -36,13 +36,13 @@ int dpkg_deb_main(int argc, char **argv)
ar_archive->filter = filter_accept_list_reassign;
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
- ar_archive->accept = llist_add_to(NULL, "data.tar.gz");
- control_tar_llist = llist_add_to(NULL, "control.tar.gz");
+ llist_add_to(&(ar_archive->accept), "data.tar.gz");
+ llist_add_to(&control_tar_llist, "control.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
- ar_archive->accept = llist_add_to(ar_archive->accept, "data.tar.bz2");
- control_tar_llist = llist_add_to(control_tar_llist, "control.tar.bz2");
+ llist_add_to(&(ar_archive->accept), "data.tar.bz2");
+ llist_add_to(&control_tar_llist, "control.tar.bz2");
#endif
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)
* it should accept a second argument which specifies a
* specific field to print */
ar_archive->accept = control_tar_llist;
- tar_archive->accept = llist_add_to(NULL, "./control");
+ llist_add_to(&(tar_archive->accept), "./control");
tar_archive->filter = filter_accept_list;
tar_archive->action_data = data_extract_to_stdout;
}
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index cd38f45..c9308f9 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)
archive_handle->action_header(archive_handle->file_header);
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
archive_handle->action_data(archive_handle);
- archive_handle->passed = llist_add_to(archive_handle->passed, file_header->name);
+ llist_add_to(&(archive_handle->passed), file_header->name);
} else {
data_skip(archive_handle);
}
diff --git a/archival/libunarchive/init_handle.c b/archival/libunarchive/init_handle.c
index 3cee84f..1813131 100644
--- a/archival/libunarchive/init_handle.c
+++ b/archival/libunarchive/init_handle.c
@@ -24,8 +24,7 @@ archive_handle_t *init_handle(void)
archive_handle_t *archive_handle;
/* Initialise default values */
- archive_handle = xmalloc(sizeof(archive_handle_t));
- memset(archive_handle, 0, sizeof(archive_handle_t));
+ archive_handle = xzalloc(sizeof(archive_handle_t));
archive_handle->file_header = xmalloc(sizeof(file_header_t));
archive_handle->action_header = header_skip;
archive_handle->action_data = data_skip;
diff --git a/archival/tar.c b/archival/tar.c
index e4008b0..f3594f6 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -551,7 +551,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
cur = cur->link;
free(tmp);
while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL)
- newlist = llist_add_to(newlist, line);
+ llist_add_to(&newlist, line);
fclose(src_stream);
}
return newlist;
@@ -800,7 +800,7 @@ int tar_main(int argc, char **argv)
if (filename_ptr > argv[optind])
*filename_ptr = '\0';
- tar_handle->accept = llist_add_to(tar_handle->accept, argv[optind]);
+ llist_add_to(&(tar_handle->accept), argv[optind]);
optind++;
}
diff --git a/archival/unzip.c b/archival/unzip.c
index 2cb256c..0b1e6f9 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -180,7 +180,7 @@ int unzip_main(int argc, char **argv)
case 1: /* Include files */
if (opt == 1) {
- zaccept = llist_add_to(zaccept, optarg);
+ llist_add_to(&zaccept, optarg);
} else if (opt == 'd') {
base_dir = optarg;
@@ -196,7 +196,7 @@ int unzip_main(int argc, char **argv)
case 2 : /* Exclude files */
if (opt == 1) {
- zreject = llist_add_to(zreject, optarg);
+ llist_add_to(&zreject, optarg);
} else if (opt == 'd') { /* Extract to base directory */
base_dir = optarg;
diff --git a/editors/sed.c b/editors/sed.c
index a17d1e5..6585a60 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -683,7 +683,7 @@ static sed_cmd_t *branch_to(const char *label)
static void append(char *s)
{
- bbg.append_head = llist_add_to_end(bbg.append_head, bb_xstrdup(s));
+ llist_add_to_end(&bbg.append_head, bb_xstrdup(s));
}
static void flush_append(void)
diff --git a/findutils/grep.c b/findutils/grep.c
index e5b5e32..fac2969 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -273,7 +273,7 @@ static void load_regexes_from_file(llist_t *fopt)
free(cur);
f = bb_xfopen(ffile, "r");
while ((line = bb_get_chomped_line_from_file(f)) != NULL) {
- pattern_head = llist_add_to(pattern_head,
+ llist_add_to(&pattern_head,
new_grep_list_data(line, PATTERN_MEM_A));
}
}
@@ -373,7 +373,7 @@ int grep_main(int argc, char **argv)
else {
char *pattern = new_grep_list_data(*argv++, 0);
- pattern_head = llist_add_to(pattern_head, pattern);
+ llist_add_to(&pattern_head, pattern);
argc--;
}
}
diff --git a/include/libbb.h b/include/libbb.h
index 93b29c6..3bb663b 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -84,8 +84,8 @@ typedef struct llist_s {
char *data;
struct llist_s *link;
} llist_t;
-extern llist_t *llist_add_to(llist_t *old_head, void *data);
-extern llist_t *llist_add_to_end(llist_t *list_head, void *data);
+extern void llist_add_to(llist_t **old_head, void *data);
+extern void llist_add_to_end(llist_t **list_head, void *data);
extern void *llist_pop(llist_t **elm);
extern void llist_free(llist_t *elm, void (*freeit)(void *data));
diff --git a/libbb/getopt_ulflags.c b/libbb/getopt_ulflags.c
index 76bdeed..dc40095 100644
--- a/libbb/getopt_ulflags.c
+++ b/libbb/getopt_ulflags.c
@@ -474,8 +474,7 @@ loop_arg_is_opt:
if(on_off->counter)
(*(on_off->counter))++;
if(on_off->list_flg) {
- *(llist_t **)(on_off->optarg) =
- llist_add_to(*(llist_t **)(on_off->optarg), optarg);
+ llist_add_to((llist_t **)(on_off->optarg), optarg);
} else if (on_off->optarg) {
*(char **)(on_off->optarg) = optarg;
}
diff --git a/libbb/llist.c b/libbb/llist.c
index dd80436..fde25e8 100644
--- a/libbb/llist.c
+++ b/libbb/llist.c
@@ -14,37 +14,29 @@
#ifdef L_llist_add_to
/* Add data to the start of the linked list. */
-llist_t *llist_add_to(llist_t *old_head, void *data)
+void llist_add_to(llist_t **old_head, void *data)
{
- llist_t *new_head;
-
- new_head = xmalloc(sizeof(llist_t));
+ llist_t *new_head = xmalloc(sizeof(llist_t));
new_head->data = data;
- new_head->link = old_head;
-
- return (new_head);
+ new_head->link = *old_head;
+ *old_head = new_head;
}
#endif
#ifdef L_llist_add_to_end
/* Add data to the end of the linked list. */
-llist_t *llist_add_to_end(llist_t *list_head, void *data)
+void llist_add_to_end(llist_t **list_head, void *data)
{
- llist_t *new_item;
-
- new_item = xmalloc(sizeof(llist_t));
+ llist_t *new_item = xmalloc(sizeof(llist_t));
new_item->data = data;
new_item->link = NULL;
- if (list_head == NULL) {
- list_head = new_item;
- } else {
- llist_t *tail = list_head;
- while (tail->link)
- tail = tail->link;
+ if (!*list_head) *list_head = new_item;
+ else {
+ llist_t *tail = *list_head;
+ while (tail->link) tail = tail->link;
tail->link = new_item;
}
- return list_head;
}
#endif
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 32b92fb..038bb13 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -739,7 +739,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
}
}
- defn->ifaces = llist_add_to_end(defn->ifaces, (char*)currif);
+ llist_add_to_end(&(defn->ifaces), (char*)currif);
}
debug_noise("iface %s %s %s\n", currif->iface, address_family_name, method_name);
}
@@ -753,7 +753,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
}
/* Add the interface to the list */
- defn->autointerfaces = llist_add_to_end(defn->autointerfaces, bb_xstrdup(firstword));
+ llist_add_to_end(&(defn->autointerfaces), bb_xstrdup(firstword));
debug_noise("\nauto %s\n", firstword);
}
currently_processing = NONE;
@@ -1202,14 +1202,14 @@ int ifupdown_main(int argc, char **argv)
/* iface_down */
const llist_t *list = state_list;
while (list) {
- target_list = llist_add_to_end(target_list, bb_xstrdup(list->data));
+ llist_add_to_end(&target_list, bb_xstrdup(list->data));
list = list->link;
}
target_list = defn->autointerfaces;
#endif
}
} else {
- target_list = llist_add_to_end(target_list, argv[optind]);
+ llist_add_to_end(&target_list, argv[optind]);
}
@@ -1311,7 +1311,7 @@ int ifupdown_main(int argc, char **argv)
char *newiface = xmalloc(strlen(iface) + 1 + strlen(liface) + 1);
sprintf(newiface, "%s=%s", iface, liface);
if (iface_state == NULL) {
- state_list = llist_add_to_end(state_list, newiface);
+ llist_add_to_end(&state_list, newiface);
} else {
free(iface_state->data);
iface_state->data = newiface;
diff --git a/procps/pidof.c b/procps/pidof.c
index 98008aa..4ad6b15 100644
--- a/procps/pidof.c
+++ b/procps/pidof.c
@@ -67,12 +67,7 @@ int pidof_main(int argc, char **argv)
if (!strncmp(omits_p->data, "%PPID", 5)) {
llist_pop(&omits_p);
snprintf(getppid_str, sizeof(getppid_str), "%d", getppid());
- omits_p = llist_add_to(omits_p, getppid_str);
-#if 0
- } else {
- bb_error_msg_and_die("illegal omit pid value (%s)!\n",
- omits_p->data);
-#endif
+ llist_add_to(&omits_p, getppid_str);
}
omits_p = omits_p->link;
}
diff --git a/util-linux/mount.c b/util-linux/mount.c
index a191f32..e1c1c60 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -169,7 +169,7 @@ static llist_t *get_block_backed_filesystems(void)
if(*fs=='#' || *fs=='*') continue;
if(!*fs) continue;
- list=llist_add_to_end(list,bb_xstrdup(fs));
+ llist_add_to_end(&list,bb_xstrdup(fs));
}
if (ENABLE_FEATURE_CLEAN_UP) fclose(f);
}