svn commit: trunk/busybox: archival archival/libunarchive editors f etc...

landley at busybox.net landley at busybox.net
Fri May 26 23:44:55 UTC 2006


Author: landley
Date: 2006-05-26 16:44:51 -0700 (Fri, 26 May 2006)
New Revision: 15199

Log:
Change llist_add_* to take the address of the list rather than returning the new
head, and change all the callers.


Modified:
   trunk/busybox/archival/ar.c
   trunk/busybox/archival/cpio.c
   trunk/busybox/archival/dpkg.c
   trunk/busybox/archival/dpkg_deb.c
   trunk/busybox/archival/libunarchive/get_header_tar.c
   trunk/busybox/archival/libunarchive/init_handle.c
   trunk/busybox/archival/tar.c
   trunk/busybox/archival/unzip.c
   trunk/busybox/editors/sed.c
   trunk/busybox/findutils/grep.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/getopt_ulflags.c
   trunk/busybox/libbb/llist.c
   trunk/busybox/networking/ifupdown.c
   trunk/busybox/procps/pidof.c
   trunk/busybox/util-linux/mount.c


Changeset:
Modified: trunk/busybox/archival/ar.c
===================================================================
--- trunk/busybox/archival/ar.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/archival/ar.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -97,7 +97,7 @@
 
 	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);

Modified: trunk/busybox/archival/cpio.c
===================================================================
--- trunk/busybox/archival/cpio.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/archival/cpio.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -88,7 +88,7 @@
 
 	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++;
 	}
 

Modified: trunk/busybox/archival/dpkg.c
===================================================================
--- trunk/busybox/archival/dpkg.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/archival/dpkg.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -1484,10 +1484,10 @@
 
 	/* 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 @@
 
 	/* 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 @@
 	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 @@
 			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);

Modified: trunk/busybox/archival/dpkg_deb.c
===================================================================
--- trunk/busybox/archival/dpkg_deb.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/archival/dpkg_deb.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -36,13 +36,13 @@
 	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 @@
 		 * 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;
 	}

Modified: trunk/busybox/archival/libunarchive/get_header_tar.c
===================================================================
--- trunk/busybox/archival/libunarchive/get_header_tar.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/archival/libunarchive/get_header_tar.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -206,7 +206,7 @@
 		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);
 	}

Modified: trunk/busybox/archival/libunarchive/init_handle.c
===================================================================
--- trunk/busybox/archival/libunarchive/init_handle.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/archival/libunarchive/init_handle.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -24,8 +24,7 @@
 	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;

Modified: trunk/busybox/archival/tar.c
===================================================================
--- trunk/busybox/archival/tar.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/archival/tar.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -551,7 +551,7 @@
 		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 @@
 		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++;
 	}
 

Modified: trunk/busybox/archival/unzip.c
===================================================================
--- trunk/busybox/archival/unzip.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/archival/unzip.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -180,7 +180,7 @@
 
 		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 @@
 
 		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;

Modified: trunk/busybox/editors/sed.c
===================================================================
--- trunk/busybox/editors/sed.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/editors/sed.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -683,7 +683,7 @@
 
 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)

Modified: trunk/busybox/findutils/grep.c
===================================================================
--- trunk/busybox/findutils/grep.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/findutils/grep.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -273,7 +273,7 @@
 		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 @@
 		else {
 			char *pattern = new_grep_list_data(*argv++, 0);
 
-			pattern_head = llist_add_to(pattern_head, pattern);
+			llist_add_to(&pattern_head, pattern);
 			argc--;
 		}
 	}

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/include/libbb.h	2006-05-26 23:44:51 UTC (rev 15199)
@@ -84,8 +84,8 @@
 	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));
 

Modified: trunk/busybox/libbb/getopt_ulflags.c
===================================================================
--- trunk/busybox/libbb/getopt_ulflags.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/libbb/getopt_ulflags.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -474,8 +474,7 @@
 		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;
 		}

Modified: trunk/busybox/libbb/llist.c
===================================================================
--- trunk/busybox/libbb/llist.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/libbb/llist.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -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
 

Modified: trunk/busybox/networking/ifupdown.c
===================================================================
--- trunk/busybox/networking/ifupdown.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/networking/ifupdown.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -739,7 +739,7 @@
 						}
 					}
 
-					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 @@
 				}
 
 				/* 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 @@
 			/* 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 @@
 				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;

Modified: trunk/busybox/procps/pidof.c
===================================================================
--- trunk/busybox/procps/pidof.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/procps/pidof.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -67,12 +67,7 @@
 			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;
 		}

Modified: trunk/busybox/util-linux/mount.c
===================================================================
--- trunk/busybox/util-linux/mount.c	2006-05-26 23:00:10 UTC (rev 15198)
+++ trunk/busybox/util-linux/mount.c	2006-05-26 23:44:51 UTC (rev 15199)
@@ -169,7 +169,7 @@
 			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);
 	}




More information about the busybox-cvs mailing list