summaryrefslogtreecommitdiff
path: root/networking/udhcp/common.c
diff options
context:
space:
mode:
authorDenys Vlasenko2013-05-17 15:19:47 +0200
committerDenys Vlasenko2013-05-17 15:19:47 +0200
commitb443a3780d5a9f8c65c5690b7f5f4bfc2ea8134b (patch)
treed3dbaa4ec4d0f7c8c95a723425797b782d2604c4 /networking/udhcp/common.c
parentc133fa66f37d69efb0d2e10ad2e068564933d92c (diff)
downloadbusybox-b443a3780d5a9f8c65c5690b7f5f4bfc2ea8134b.zip
busybox-b443a3780d5a9f8c65c5690b7f5f4bfc2ea8134b.tar.gz
udhcp: code shrink
function old new delta attach_option 416 413 -3 allocate_tempopt_if_needed 74 - -74 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/common.c')
-rw-r--r--networking/udhcp/common.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index 9c27cd0..11b7b1f 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -371,20 +371,23 @@ static NOINLINE void attach_option(
char *buffer,
int length)
{
- struct option_set *existing, *new, **curr;
- char *allocated = NULL;
+ struct option_set *existing;
+ char *allocated;
- existing = udhcp_find_option(*opt_list, optflag->code);
- if (!existing) {
- log2("Attaching option %02x to list", optflag->code);
- allocated = allocate_tempopt_if_needed(optflag, buffer, &length);
+ allocated = allocate_tempopt_if_needed(optflag, buffer, &length);
#if ENABLE_FEATURE_UDHCP_RFC3397
- if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {
- /* reuse buffer and length for RFC1035-formatted string */
- allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length);
- }
+ if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {
+ /* reuse buffer and length for RFC1035-formatted string */
+ allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length);
+ }
#endif
+
+ existing = udhcp_find_option(*opt_list, optflag->code);
+ if (!existing) {
+ struct option_set *new, **curr;
+
/* make a new option */
+ log2("Attaching option %02x to list", optflag->code);
new = xmalloc(sizeof(*new));
new->data = xmalloc(length + OPT_DATA);
new->data[OPT_CODE] = optflag->code;
@@ -405,14 +408,7 @@ static NOINLINE void attach_option(
/* add it to an existing option */
log2("Attaching option %02x to existing member of list", optflag->code);
- allocated = allocate_tempopt_if_needed(optflag, buffer, &length);
old_len = existing->data[OPT_LEN];
-#if ENABLE_FEATURE_UDHCP_RFC3397
- if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {
- /* reuse buffer and length for RFC1035-formatted string */
- allocated = buffer = (char *)dname_enc(existing->data + OPT_DATA, old_len, buffer, &length);
- }
-#endif
if (old_len + length < 255) {
/* actually 255 is ok too, but adding a space can overlow it */