[BusyBox] Re: ifconfig: Clean up. [PATCH]
Shaun Jackman
sjackman at gmail.com
Tue Jul 26 10:14:36 MDT 2005
On 7/26/05, Rob Landley <rob at landley.net> wrote:
> If we're going to do this (and I suppose the fact that CONFIG_FEATURE_CLEAN_UP
> is a symbol we're already familiar with outweights the fact it's a bit
> verbose and loud), then we really should have the build process generate
> these programmatically. I.E. add the following to the config.h generator in
> the build file:
>
> sed -e 's/#undef CONFIG_\(.*\)/#define CONFIG_\1 0/' -i config.h
>
> Note that this misses "USING_CROSS_COMPILER", and that I personally don't
> care.
The above sed script has the problem that it defines CONFIG_xxx to 0
when the same variable was previously undefined. Since most of the
busybox code uses #ifdef CONFIG_xxx rather than #if CONFIG_xxx, this
will break things. If #define CONFIG_xxx 1 is used for the positive
case, and static const int CONFIG_xxx = 0; is used for the negative
case, all common cases work, including...
#ifdef CONFIG_xxx
#if CONFIG_xxx
if (CONFIG_xxx)
Here's the script...
sed -e 's/#undef \(.*\)/static const int \1 = 0;/' < include/config.h
> include/bb_config.h
... and the patch.
Cheers,
Shaun
2005-07-26 Shaun Jackman <sjackman at gmail.com>
* Makefile: Build include/bb_config.h.
* include/busybox.h: Include include/bb_config.h.
* include/libbb.h: Ditto.
* networking/ifconfig.c: Include unistd.h.
(ifconfig_main): Clean up the file descriptor.
Index: networking/ifconfig.c
===================================================================
--- networking/ifconfig.c (revision 10914)
+++ networking/ifconfig.c (working copy)
@@ -37,6 +37,7 @@
#include <string.h> /* strcmp and friends */
#include <ctype.h> /* isdigit and friends */
#include <stddef.h> /* offsetof */
+#include <unistd.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <net/if.h>
@@ -558,6 +559,7 @@
continue;
} /* end of while-loop */
+ if (CONFIG_FEATURE_CLEAN_UP) close(sockfd);
return goterr;
}
Index: Makefile
===================================================================
--- Makefile (revision 10914)
+++ Makefile (working copy)
@@ -122,7 +122,7 @@
include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
-include $(top_builddir)/.depend
-busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y)
+busybox: $(ALL_MAKEFILES) .depend include/bb_config.h $(libraries-y)
$(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES)
-Wl,--end-group
$(STRIPCMD) $@
@@ -212,6 +212,9 @@
fi;
@$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
+include/bb_config.h: include/config.h
+ sed -e 's/#undef \(.*\)/static const int \1 = 0;/' < $< > $@
+
finished2:
@echo
@echo Finished installing...
@@ -279,7 +282,7 @@
distclean: clean
- rm -f scripts/split-include scripts/mkdep
- - rm -rf include/config include/config.h
+ - rm -rf include/config include/config.h include/bb_config.h
- find . -name .depend -exec rm -f {} \;
rm -f .config .config.old .config.cmd
- $(MAKE) -C scripts/config clean
Index: include/libbb.h
===================================================================
--- include/libbb.h (revision 10914)
+++ include/libbb.h (working copy)
@@ -41,7 +41,9 @@
#include <features.h>
-#include "config.h"
+#ifndef AUTOCONF_INCLUDED
+# include "bb_config.h"
+#endif
#ifdef CONFIG_SELINUX
#include <selinux/selinux.h>
#endif
Index: include/busybox.h
===================================================================
--- include/busybox.h (revision 10914)
+++ include/busybox.h (working copy)
@@ -24,7 +24,9 @@
#ifndef _BB_INTERNAL_H_
#define _BB_INTERNAL_H_ 1
-#include "config.h"
+#ifndef AUTOCONF_INCLUDED
+# include "bb_config.h"
+#endif
#include <stdio.h>
#include <stdlib.h>
More information about the busybox
mailing list