All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
To: Ramon Fried <rfried.dev@gmail.com>
Cc: u-boot@lists.denx.de, Fabio Estevam <festevam@denx.de>,
	Nicolas Bidron <nicolas.bidron@nccgroup.com>,
	Tom Rini <trini@konsulko.com>,
	Joe Hershberger <joe.hershberger@ni.com>
Subject: Re: [PATCH 5/6] net: tftp: use IS_ENABLED(CONFIG_NET_TFTP_VARS) instead of #if
Date: Mon, 17 Oct 2022 08:18:51 +0200	[thread overview]
Message-ID: <5c79eb7d-0f56-c152-4232-5bb13bb001b5@prevas.dk> (raw)
In-Reply-To: <CAGi-RULVFi9wW97VrCVhkc=H3urYQNpYRHzBF5EaGXpLRMOSnA@mail.gmail.com>

On 16/10/2022 20.28, Ramon Fried wrote:
> On Fri, Oct 14, 2022 at 8:44 PM Rasmus Villemoes
> <rasmus.villemoes@prevas.dk> wrote:
>>
>> Nothing inside this block depends on NET_TFTP_VARS to be set to parse
>> correctly. Switch to C if() in preparation for adding code before
>> this (to avoid a declaration-after-statement warning).
> What's the motivation here ? The #ifdef is supposed to allow smaller
> code size if feature is not used.

And as always with these types of conversions, nothing changes in that
regard - an "if (0)" is optimized out by the compiler just fine.

The motivation is in the commit message: The following patch will need
to add a bit of logic at the very beginning of the function, so if I
left the #ifdef block as-is, the declaration of the ep variable would
lead to a declaration-after-statement warning; lifting the declaration
to the top would either require repeating the ugly ifdeffery, or give a
"variable not used" warning.

It's also in general the preferred method, because it means the
contained code gets checked for syntactic correctness regardless of
.config - but that very same thing is also why it cannot be applied
universally, if the contained code e.g. refers to struct fields that are
only defined with certain CONFIG_FOO set [and this also was alluded to
in the commit message].

Rasmus

  reply	other threads:[~2022-10-17  6:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 17:43 [PATCH 0/6] broken CVE fix (b85d130ea0ca) Rasmus Villemoes
2022-10-14 17:43 ` [PATCH 1/6] net: improve check for no IP options Rasmus Villemoes
2022-10-16 18:23   ` Ramon Fried
2022-11-28 19:51   ` Tom Rini
2022-10-14 17:43 ` [PATCH 2/6] net: compare received length to sizeof(ip_hdr), not sizeof(ip_udp_hdr) Rasmus Villemoes
2022-11-28 19:51   ` Tom Rini
2022-10-14 17:43 ` [PATCH 3/6] net: (actually/better) deal with CVE-2022-{30790,30552} Rasmus Villemoes
2022-11-28 19:51   ` Tom Rini
2022-10-14 17:43 ` [PATCH 4/6] net: fix ip_len in reassembled IP datagram Rasmus Villemoes
2022-11-28 19:51   ` Tom Rini
2022-10-14 17:43 ` [PATCH 5/6] net: tftp: use IS_ENABLED(CONFIG_NET_TFTP_VARS) instead of #if Rasmus Villemoes
2022-10-16 18:28   ` Ramon Fried
2022-10-17  6:18     ` Rasmus Villemoes [this message]
2022-11-28 19:51   ` Tom Rini
2022-10-14 17:43 ` [PATCH 6/6] net: tftp: sanitize tftp block size, especially for TX Rasmus Villemoes
2022-10-16 18:30   ` Ramon Fried
2022-11-28 19:51   ` Tom Rini
2022-10-15 12:57 ` [PATCH 0/6] broken CVE fix (b85d130ea0ca) Fabio Estevam
2022-10-17  7:52 ` [PATCH 7/6] net: deal with fragment-overlapping-two-holes case Rasmus Villemoes
2022-11-28 19:52   ` Tom Rini
2022-11-14  9:35 ` [PATCH 0/6] broken CVE fix (b85d130ea0ca) Rasmus Villemoes
2022-11-14 13:04   ` Tom Rini
2022-11-17  0:32     ` Fabio Estevam
2022-11-28  8:10       ` Rasmus Villemoes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c79eb7d-0f56-c152-4232-5bb13bb001b5@prevas.dk \
    --to=rasmus.villemoes@prevas.dk \
    --cc=festevam@denx.de \
    --cc=joe.hershberger@ni.com \
    --cc=nicolas.bidron@nccgroup.com \
    --cc=rfried.dev@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.