[PATCH] dhcpc: refactor xmalloc_optname_optval to shrink binary size

Denys Vlasenko vda.linux at googlemail.com
Tue Jun 9 16:00:50 UTC 2020


Applied, thanks!

On Tue, Jun 9, 2020 at 5:05 PM Martin Lewis <martin.lewis.x84 at gmail.com> wrote:
> @@ -272,12 +270,12 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_
>                                 len--;
>
>                                 nip = 0;
> -                               p = (void*) &nip;
>                                 bytes = (mask + 7) / 8; /* 0 -> 0, 1..8 -> 1, 9..16 -> 2 etc */
> -                               while (--bytes >= 0) {
> -                                       *p++ = *option++;
> -                                       len--;
> -                               }
> +
> +                               memcpy(&nip, option, bytes);
> +                               len -= bytes;
> +                               option += bytes;
> +
>                                 if (len < 4)
>                                         break;
>

On my system, this part wasn't giving smaller code.


More information about the busybox mailing list