[BusyBox] Re: ifconfig: Clean up. [PATCH]
Shaun Jackman
sjackman at gmail.com
Tue Jul 26 06:55:09 UTC 2005
On 7/25/05, Rob Landley <rob at landley.net> wrote:
> > I'd to spell do_cleanup as DO_CLEANUP. If I saw...
> > if (DO_CLEANUP)
> > ... I'd understand it was a conditional compilation. If I saw...
> > if (do_cleanup)
>
> I was actually thinking of a static const int.
Getting back to the original thread of conversation, here's an
implementation of my previous idea. I rather like the consistency this
method offers.
Cheers,
Shaun
2005-07-25 Shaun Jackman <sjackman at gmail.com>
* include/busybox.h (CONFIG_FEATURE_CLEAN_UP): New static const int.
* networking/ifconfig.c (ifconfig_main): Clean up the file descriptor.
Index: include/busybox.h
===================================================================
--- include/busybox.h (revision 10914)
+++ include/busybox.h (working copy)
@@ -103,6 +103,9 @@
#endif
#endif
+#ifndef CONFIG_FEATURE_CLEAN_UP
+static const int CONFIG_FEATURE_CLEAN_UP = 0;
+#endif
#ifndef RB_POWER_OFF
/* Stop system and switch power off if possible. */
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;
}
More information about the busybox
mailing list