[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87wm90mdws.ffs@tglx>
Date: Wed, 25 Jun 2025 10:19:31 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Paolo Abeni <pabeni@...hat.com>, LKML <linux-kernel@...r.kernel.org>
Cc: Richard Cochran <richardcochran@...il.com>, netdev@...r.kernel.org
Subject: Re: [patch 08/13] ptp: Split out PTP_PIN_GETFUNC ioctl code
On Tue, Jun 24 2025 at 15:39, Thomas Gleixner wrote:
> On Tue, Jun 24 2025 at 11:22, Paolo Abeni wrote:
>>> + if (cmd == PTP_PIN_GETFUNC2 && !mem_is_zero(pd.rsv, sizeof(pd.rsv)))
>>> + return -EINVAL;
>>> + else
>>> + memset(pd.rsv, 0, sizeof(pd.rsv));
>>
>> Minor nit: I personally find the 'else' statement after return
>> counter-intuitive and dropping it would save an additional LoC.
>
> Of course ...
But second thoughts. The actual logic here is:
if (cmd == PTP_PIN_GETFUNC2) {
if (!mem_is_zero(pd.rsv, sizeof(pd.rsv)))
return -EINVAL;
} else {
memset(pd.rsv, 0, sizeof(pd.rsv));
}
because PTP_PIN_GETFUNC did not mandate the reserved fields to be zero,
which means the reserved fields can never be used with that opcode.
But as it stands today, pd.rsv is not used at all in that function and
pd is fully overwritten via pd = pd->ops_config[] later. So the memset
is completely useless right now and can go away completely.
Thanks,
tglx
Powered by blists - more mailing lists