[patch] remove a few unnecessary #includes

Bernhard Fischer rep.nop at aon.at
Sat Sep 10 19:15:41 UTC 2005


Hi,

Tested with allyesconfig.

- remove some unnecessary #includes
- trim a bit of the superfluous whitespace in cpio.c
- use ENABLE_FEATURE_CLEAN_UP in readlink.c

% diffstat ./busybox.remove-unneeded-includes.01.diff
 archival/ar.c                             |    1 -
 archival/bunzip2.c                        |    3 +--
 archival/cpio.c                           |   17 ++++++++---------
 archival/dpkg_deb.c                       |    1 -
 archival/gunzip.c                         |    1 -
 archival/libunarchive/unpack_ar_archive.c |    1 -
 archival/uncompress.c                     |    1 -
 archival/unzip.c                          |    1 -
 console-tools/setconsole.c                |    2 +-
 coreutils/cut.c                           |    1 -
 coreutils/date.c                          |    1 -
 coreutils/dos2unix.c                      |    1 -
 coreutils/env.c                           |    2 +-
 coreutils/install.c                       |    2 +-
 coreutils/ls.c                            |    2 +-
 coreutils/mkdir.c                         |    2 +-
 coreutils/mv.c                            |    2 +-
 coreutils/stat.c                          |    2 +-
 coreutils/sum.c                           |    1 -
 coreutils/uudecode.c                      |    2 +-
 coreutils/uuencode.c                      |    1 -
 debianutils/readlink.c                    |    7 ++-----
 debianutils/start_stop_daemon.c           |    2 +-
 23 files changed, 20 insertions(+), 36 deletions(-)


please apply.
PS: this only covers half of the tree, i'll do the rest if someone tells
me that this is ok and applies it.

thanks,
Bernhard
-------------- next part --------------
diff -X excl -rduNp busybox.busybox.oorig/archival/ar.c busybox.busybox/archival/ar.c
--- busybox.busybox.oorig/archival/ar.c	2005-09-05 21:44:14.000000000 +0200
+++ busybox.busybox/archival/ar.c	2005-09-10 13:07:01.000000000 +0200
@@ -27,7 +27,6 @@
  */
 
 #include <fcntl.h>
-#include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff -X excl -rduNp busybox.busybox.oorig/archival/bunzip2.c busybox.busybox/archival/bunzip2.c
--- busybox.busybox.oorig/archival/bunzip2.c	2005-09-02 09:45:28.000000000 +0200
+++ busybox.busybox/archival/bunzip2.c	2005-09-09 22:13:12.000000000 +0200
@@ -6,7 +6,6 @@
  */
 
 #include <fcntl.h>
-#include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -35,7 +34,7 @@ int bunzip2_main(int argc, char **argv)
 		src_fd = STDIN_FILENO;
 		filename = 0;
 	}
-	
+
 	/* if called as bzcat force the stdout flag */
 	if ((opt & BUNZIP2_OPT_STDOUT) || bb_applet_name[2] == 'c')
 		filename = 0;
diff -X excl -rduNp busybox.busybox.oorig/archival/cpio.c busybox.busybox/archival/cpio.c
--- busybox.busybox.oorig/archival/cpio.c	2005-04-01 22:05:36.000000000 +0200
+++ busybox.busybox/archival/cpio.c	2005-09-09 22:11:37.000000000 +0200
@@ -24,20 +24,19 @@
  *
  */
 #include <fcntl.h>
-#include <getopt.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include "unarchive.h"
 #include "busybox.h"
 
-#define CPIO_OPT_EXTRACT           	0x01
-#define CPIO_OPT_TEST              	0x02
-#define CPIO_OPT_UNCONDITIONAL     	0x04
-#define CPIO_OPT_VERBOSE           	0x08
-#define CPIO_OPT_FILE              	0x10
+#define CPIO_OPT_EXTRACT			0x01
+#define CPIO_OPT_TEST				0x02
+#define CPIO_OPT_UNCONDITIONAL		0x04
+#define CPIO_OPT_VERBOSE			0x08
+#define CPIO_OPT_FILE				0x10
 #define CPIO_OPT_CREATE_LEADING_DIR	0x20
-#define CPIO_OPT_PRESERVE_MTIME    	0x40
+#define CPIO_OPT_PRESERVE_MTIME		0x40
 
 extern int cpio_main(int argc, char **argv)
 {
@@ -59,7 +58,7 @@ extern int cpio_main(int argc, char **ar
 	}
 
 	if (opt & CPIO_OPT_TEST) {
-		/* if both extract and test option are given, ignore extract option */
+		/* if both extract and test options are given, ignore extract option */
 		if (opt & CPIO_OPT_EXTRACT) {
 			opt &= ~CPIO_OPT_EXTRACT;
 		}
@@ -79,7 +78,7 @@ extern int cpio_main(int argc, char **ar
 			archive_handle->action_header = header_list;
 		}
 	}
-	if (cpio_filename) {	/* CPIO_OPT_FILE */
+	if (cpio_filename) { /* CPIO_OPT_FILE */
 		archive_handle->src_fd = bb_xopen(cpio_filename, O_RDONLY);
 		archive_handle->seek = seek_by_jump;
 	}
diff -X excl -rduNp busybox.busybox.oorig/archival/dpkg_deb.c busybox.busybox/archival/dpkg_deb.c
--- busybox.busybox.oorig/archival/dpkg_deb.c	2005-09-05 21:44:14.000000000 +0200
+++ busybox.busybox/archival/dpkg_deb.c	2005-09-10 13:08:05.000000000 +0200
@@ -18,7 +18,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <getopt.h>
 
 #include "unarchive.h"
 #include "busybox.h"
diff -X excl -rduNp busybox.busybox.oorig/archival/gunzip.c busybox.busybox/archival/gunzip.c
--- busybox.busybox.oorig/archival/gunzip.c	2005-04-01 22:05:36.000000000 +0200
+++ busybox.busybox/archival/gunzip.c	2005-09-10 13:07:41.000000000 +0200
@@ -63,7 +63,6 @@ static char *license_msg[] = {
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <getopt.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff -X excl -rduNp busybox.busybox.oorig/archival/libunarchive/unpack_ar_archive.c busybox.busybox/archival/libunarchive/unpack_ar_archive.c
--- busybox.busybox.oorig/archival/libunarchive/unpack_ar_archive.c	2005-04-01 22:05:36.000000000 +0200
+++ busybox.busybox/archival/libunarchive/unpack_ar_archive.c	2005-09-10 12:51:38.000000000 +0200
@@ -16,7 +16,6 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
-#include <getopt.h>
 #include "unarchive.h"
 #include "busybox.h"
 
diff -X excl -rduNp busybox.busybox.oorig/archival/uncompress.c busybox.busybox/archival/uncompress.c
--- busybox.busybox.oorig/archival/uncompress.c	2005-04-01 22:05:36.000000000 +0200
+++ busybox.busybox/archival/uncompress.c	2005-09-10 13:00:07.000000000 +0200
@@ -20,7 +20,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <getopt.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff -X excl -rduNp busybox.busybox.oorig/archival/unzip.c busybox.busybox/archival/unzip.c
--- busybox.busybox.oorig/archival/unzip.c	2005-08-08 19:38:05.000000000 +0200
+++ busybox.busybox/archival/unzip.c	2005-09-10 12:51:09.000000000 +0200
@@ -38,7 +38,6 @@
  */
 
 #include <fcntl.h>
-#include <getopt.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
diff -X excl -rduNp busybox.busybox.oorig/console-tools/setconsole.c busybox.busybox/console-tools/setconsole.c
--- busybox.busybox.oorig/console-tools/setconsole.c	2005-09-08 20:06:20.000000000 +0200
+++ busybox.busybox/console-tools/setconsole.c	2005-09-10 13:19:22.000000000 +0200
@@ -24,7 +24,7 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <stdio.h>
-#include <getopt.h>
+#include <getopt.h> /* struct option */
 
 #include "busybox.h"
 
diff -X excl -rduNp busybox.busybox.oorig/coreutils/cut.c busybox.busybox/coreutils/cut.c
--- busybox.busybox.oorig/coreutils/cut.c	2005-09-05 21:44:17.000000000 +0200
+++ busybox.busybox/coreutils/cut.c	2005-09-10 13:11:47.000000000 +0200
@@ -23,7 +23,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <getopt.h>
 #include <unistd.h>
 #include <string.h>
 #include <limits.h>
diff -X excl -rduNp busybox.busybox.oorig/coreutils/date.c busybox.busybox/coreutils/date.c
--- busybox.busybox.oorig/coreutils/date.c	2005-09-05 21:44:17.000000000 +0200
+++ busybox.busybox/coreutils/date.c	2005-09-10 13:12:14.000000000 +0200
@@ -29,7 +29,6 @@
 #include <time.h>
 #include <stdio.h>
 #include <string.h>
-#include <getopt.h>
 #include "busybox.h"
 
 
diff -X excl -rduNp busybox.busybox.oorig/coreutils/dos2unix.c busybox.busybox/coreutils/dos2unix.c
--- busybox.busybox.oorig/coreutils/dos2unix.c	2005-09-02 09:45:28.000000000 +0200
+++ busybox.busybox/coreutils/dos2unix.c	2005-09-10 13:09:04.000000000 +0200
@@ -28,7 +28,6 @@
  */
 
 #include <string.h>
-#include <getopt.h>
 #include <unistd.h>
 #include <stdint.h>
 #include <fcntl.h>
diff -X excl -rduNp busybox.busybox.oorig/coreutils/env.c busybox.busybox/coreutils/env.c
--- busybox.busybox.oorig/coreutils/env.c	2005-09-05 21:44:17.000000000 +0200
+++ busybox.busybox/coreutils/env.c	2005-09-10 13:13:58.000000000 +0200
@@ -47,7 +47,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
-#include <getopt.h>
+#include <getopt.h> /* struct option */
 #include "busybox.h"
 
 
diff -X excl -rduNp busybox.busybox.oorig/coreutils/install.c busybox.busybox/coreutils/install.c
--- busybox.busybox.oorig/coreutils/install.c	2005-09-05 21:44:17.000000000 +0200
+++ busybox.busybox/coreutils/install.c	2005-09-10 13:15:49.000000000 +0200
@@ -23,10 +23,10 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <errno.h>
-#include <getopt.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <getopt.h> /* struct option */
 
 #include "busybox.h"
 #include "libcoreutils/coreutils.h"
diff -X excl -rduNp busybox.busybox.oorig/coreutils/ls.c busybox.busybox/coreutils/ls.c
--- busybox.busybox.oorig/coreutils/ls.c	2005-09-05 21:44:17.000000000 +0200
+++ busybox.busybox/coreutils/ls.c	2005-09-10 13:10:39.000000000 +0200
@@ -60,7 +60,7 @@ enum {
 #include <fcntl.h>
 #include <signal.h>
 #include <termios.h>
-#include <getopt.h>
+#include <getopt.h> /* struct option */
 #include <sys/ioctl.h>
 #include <sys/sysmacros.h>     /* major() and minor() */
 #include "busybox.h"
diff -X excl -rduNp busybox.busybox.oorig/coreutils/mkdir.c busybox.busybox/coreutils/mkdir.c
--- busybox.busybox.oorig/coreutils/mkdir.c	2005-04-01 22:05:44.000000000 +0200
+++ busybox.busybox/coreutils/mkdir.c	2005-09-10 13:12:57.000000000 +0200
@@ -31,7 +31,7 @@
 
 #include <stdlib.h>
 #include <unistd.h>
-#include <getopt.h>
+#include <getopt.h> /* struct option */
 #include "busybox.h"
 
 static const struct option mkdir_long_options[] = {
diff -X excl -rduNp busybox.busybox.oorig/coreutils/mv.c busybox.busybox/coreutils/mv.c
--- busybox.busybox.oorig/coreutils/mv.c	2005-09-05 21:44:17.000000000 +0200
+++ busybox.busybox/coreutils/mv.c	2005-09-10 13:14:39.000000000 +0200
@@ -31,7 +31,7 @@
 #include <dirent.h>
 #include <errno.h>
 #include <stdlib.h>
-#include <getopt.h>
+#include <getopt.h> /* struct option */
 #include "busybox.h"
 #include "libcoreutils/coreutils.h"
 
diff -X excl -rduNp busybox.busybox.oorig/coreutils/stat.c busybox.busybox/coreutils/stat.c
--- busybox.busybox.oorig/coreutils/stat.c	2005-07-28 18:51:59.000000000 +0200
+++ busybox.busybox/coreutils/stat.c	2005-09-10 13:17:49.000000000 +0200
@@ -30,7 +30,7 @@
 #include <grp.h>
 #include <sys/vfs.h>
 #include <time.h>
-#include <getopt.h>
+#include <getopt.h> /* optind */
 #include <sys/stat.h>
 #include <sys/statfs.h>
 #include <sys/statvfs.h>
diff -X excl -rduNp busybox.busybox.oorig/coreutils/sum.c busybox.busybox/coreutils/sum.c
--- busybox.busybox.oorig/coreutils/sum.c	2005-05-26 11:48:07.000000000 +0200
+++ busybox.busybox/coreutils/sum.c	2005-09-10 13:11:24.000000000 +0200
@@ -30,7 +30,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <getopt.h>
 
 #include "libbb.h"
 
diff -X excl -rduNp busybox.busybox.oorig/coreutils/uudecode.c busybox.busybox/coreutils/uudecode.c
--- busybox.busybox.oorig/coreutils/uudecode.c	2005-04-01 22:05:44.000000000 +0200
+++ busybox.busybox/coreutils/uudecode.c	2005-09-10 13:18:22.000000000 +0200
@@ -24,7 +24,7 @@
 
 #include <stdio.h>
 #include <errno.h>
-#include <getopt.h>
+#include <getopt.h> /* optind */
 #include <string.h>
 #include <stdlib.h>
 
diff -X excl -rduNp busybox.busybox.oorig/coreutils/uuencode.c busybox.busybox/coreutils/uuencode.c
--- busybox.busybox.oorig/coreutils/uuencode.c	2005-04-01 22:05:44.000000000 +0200
+++ busybox.busybox/coreutils/uuencode.c	2005-09-10 13:15:03.000000000 +0200
@@ -19,7 +19,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-#include <getopt.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
diff -X excl -rduNp busybox.busybox.oorig/debianutils/readlink.c busybox.busybox/debianutils/readlink.c
--- busybox.busybox.oorig/debianutils/readlink.c	2005-04-01 22:05:37.000000000 +0200
+++ busybox.busybox/debianutils/readlink.c	2005-09-10 13:23:25.000000000 +0200
@@ -43,8 +43,6 @@ int readlink_main(int argc, char **argv)
 	RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
 #endif
 
-	/* no options, no getopt */
-
 	if (optind + 1 != argc)
 		bb_show_usage();
 
@@ -58,9 +56,8 @@ int readlink_main(int argc, char **argv)
 	if (!buf)
 		return EXIT_FAILURE;
 	puts(buf);
-#ifdef CONFIG_FEATURE_CLEAN_UP
-	free(buf);
-#endif
+
+	if (ENABLE_FEATURE_CLEAN_UP) free(buf);
 
 	return EXIT_SUCCESS;
 }
diff -X excl -rduNp busybox.busybox.oorig/debianutils/start_stop_daemon.c busybox.busybox/debianutils/start_stop_daemon.c
--- busybox.busybox.oorig/debianutils/start_stop_daemon.c	2005-09-05 21:44:14.000000000 +0200
+++ busybox.busybox/debianutils/start_stop_daemon.c	2005-09-10 13:25:04.000000000 +0200
@@ -16,7 +16,7 @@
 #include <sys/stat.h>
 #include <dirent.h>
 #include <unistd.h>
-#include <getopt.h>
+#include <getopt.h> /* struct option */
 
 #include "busybox.h"
 #include "pwd_.h"



More information about the busybox mailing list