Re: [PATCH 7/8] nss: aiforaf: Decrease stack size by scoping off large buffers.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Wed, Aug 30, 2023 at 2:21 PM Peter Krempa <pkrempa@xxxxxxxxxx> wrote:
On Wed, Aug 30, 2023 at 13:59:21 +0200, Peter Krempa wrote:
> The 'buf', 'sa' and 'hints' stack allocated helper variables are never
> used together. Decrease the stack memory usage by scoping them off into
> do-while blocks.
>
> In this instance we do not want to use dynamic allocation as this is the
> NSS module.
>
> Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> ---
>  tools/nss/libvirt_nss.c | 97 +++++++++++++++++++++++------------------
>  1 file changed, 54 insertions(+), 43 deletions(-)
>
> diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
> index 37720bf4ae..dff3c034bf 100644
> --- a/tools/nss/libvirt_nss.c
> +++ b/tools/nss/libvirt_nss.c

[...]

> -        hints = *pai;
> -        hints.ai_flags = AI_NUMERICHOST;
> -        hints.ai_family = af;
> +            hints = *pai;
> +            hints.ai_flags = AI_NUMERICHOST;
> +            hints.ai_family = af;
>
> -        if (getaddrinfo(host, NULL, &hints, &res0)) {
> -            addrList++;
> -            continue;

Ehh, self-NACK ...

Apart from moving these two continue into loops...


> -        }
> +            if (getaddrinfo(host, NULL, &hints, &res0)) {
> +                addrList++;
> +                continue;
> +            }
> +        } while (false);
>
>          for (res = res0; res; res = res->ai_next)
>              res->ai_flags = pai->ai_flags;
> --
> 2.41.0
>


Reviewed-by: Kristina Hanicova <khanicov@xxxxxxxxxx>

Kristina

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux