<div dir="ltr">Hi,<div>Yes, looks good :)</div><div><br></div><div>Martin</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 10 Jun 2020 at 10:21, Denys Vlasenko <<a href="mailto:vda.linux@googlemail.com">vda.linux@googlemail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thanks. I addressed this a bit differently. Looks good now?<br>
<br>
On Tue, Jun 9, 2020 at 4:55 PM Martin Lewis <<a href="mailto:martin.lewis.x84@gmail.com" target="_blank">martin.lewis.x84@gmail.com</a>> wrote:<br>
><br>
> The only call to dname_enc is with cstr = NULL, so most of dname_enc's logic is not used.<br>
> Therefore, we can directly call convert_dname and shrink the binary size.<br>
><br>
> function                                             old     new   delta<br>
> convert_dname                                          -     143    +143<br>
> attach_option                                        463     493     +30<br>
> dname_enc                                            445       -    -445<br>
> ------------------------------------------------------------------------------<br>
> (add/remove: 1/1 grow/shrink: 1/0 up/down: 173/-445)         Total: -272<br>
> bytes<br>
>    text    data     bss     dec     hex filename<br>
>  993252   16923    1872 1012047   f714f busybox_old<br>
>  992980   16923    1872 1011775   f703f busybox_unstripped<br>
><br>
> Signed-off-by: Martin Lewis <<a href="mailto:martin.lewis.x84@gmail.com" target="_blank">martin.lewis.x84@gmail.com</a>><br>
> ---<br>
>  networking/udhcp/common.c       | 6 +++++-<br>
>  networking/udhcp/common.h       | 1 +<br>
>  networking/udhcp/domain_codec.c | 2 +-<br>
>  3 files changed, 7 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c<br>
> index 9ec752dfc..f609bcfdb 100644<br>
> --- a/networking/udhcp/common.c<br>
> +++ b/networking/udhcp/common.c<br>
> @@ -431,7 +431,11 @@ static NOINLINE void attach_option(<br>
>  #if ENABLE_FEATURE_UDHCP_RFC3397<br>
>         if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {<br>
>                 /* reuse buffer and length for RFC1035-formatted string */<br>
> -               allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length);<br>
> +               allocated = buffer = (char *)convert_dname(buffer);<br>
> +               if (buffer == NULL)<br>
> +                       length = 0;<br>
> +               else<br>
> +                       length = strlen(buffer) + 1; /* including NUL */<br>
>         }<br>
>  #endif<br>
><br>
> diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h<br>
> index 60255eefa..7aeeb5152 100644<br>
> --- a/networking/udhcp/common.h<br>
> +++ b/networking/udhcp/common.h<br>
> @@ -219,6 +219,7 @@ void udhcp_add_simple_option(struct dhcp_packet *packet, uint8_t code, uint32_t<br>
>  #if ENABLE_FEATURE_UDHCP_RFC3397 || ENABLE_FEATURE_UDHCPC6_RFC3646 || ENABLE_FEATURE_UDHCPC6_RFC4704<br>
>  char *dname_dec(const uint8_t *cstr, int clen, const char *pre) FAST_FUNC;<br>
>  uint8_t *dname_enc(const uint8_t *cstr, int clen, const char *src, int *retlen) FAST_FUNC;<br>
> +uint8_t *convert_dname(const char *src);<br>
>  #endif<br>
>  struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) FAST_FUNC;<br>
><br>
> diff --git a/networking/udhcp/domain_codec.c b/networking/udhcp/domain_codec.c<br>
> index b7a3a5353..b5df48d87 100644<br>
> --- a/networking/udhcp/domain_codec.c<br>
> +++ b/networking/udhcp/domain_codec.c<br>
> @@ -113,7 +113,7 @@ char* FAST_FUNC dname_dec(const uint8_t *cstr, int clen, const char *pre)<br>
>   * RFC1035 encoding "\003foo\004blah\003com\000". Return allocated string, or<br>
>   * NULL if an error occurs.<br>
>   */<br>
> -static uint8_t *convert_dname(const char *src)<br>
> +uint8_t *convert_dname(const char *src)<br>
>  {<br>
>         uint8_t c, *res, *lenptr, *dst;<br>
>         int len;<br>
> --<br>
> 2.11.0<br>
><br>
> _______________________________________________<br>
> busybox mailing list<br>
> <a href="mailto:busybox@busybox.net" target="_blank">busybox@busybox.net</a><br>
> <a href="http://lists.busybox.net/mailman/listinfo/busybox" rel="noreferrer" target="_blank">http://lists.busybox.net/mailman/listinfo/busybox</a><br>
</blockquote></div>