From: Randy Dunlap <rdunlap@infradead.org>
To: Michael Witten <mfwitten@gmail.com>,
sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] openprom: Fix 'opiocnextprop'; ensure integer conversions; use string size
Date: Tue, 13 Oct 2020 23:40:28 -0700 [thread overview]
Message-ID: <c1329005-fa37-e02e-0105-2634ee566f55@infradead.org> (raw)
In-Reply-To: <a5515efeaad94666a87f264dbf65bdbd@gmail.com>
Hi,
On 9/4/20 12:40 PM, Michael Witten wrote:
> The following patch improves the quality and correctness of the openprom code.
>
>
> --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
>
> ---
> arch/sparc/include/asm/prom.h | 2 +-
> arch/sparc/kernel/prom_common.c | 14 +--
> drivers/sbus/char/openprom.c | 263 ++++++++++++++++++++++++++++------------
> 3 files changed, 194 insertions(+), 85 deletions(-)
>
> diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
> index 30b9751aad30..9bc2877aa09a 100644
> --- a/drivers/sbus/char/openprom.c
> +++ b/drivers/sbus/char/openprom.c
> /* If the bufsize is too large, just limit it.
> * Fix from Jason Rappleye.
> */
The sparc cross-compiler that I am using does not like to see type
casting in preprocessor lines.
SIZE_MAX is #defined as (~(size_t)0) and for the #if line below,
> + #if OPROMMAXPARAM > SIZE_MAX/2
> + if (bufsize > SIZE_MAX/2)
> + return -EFAULT;
> + #endif
gcc (cpp) says:
In file included from ../drivers/sbus/char/openprom.c:19:
../include/linux/limits.h:9:21: warning: "size_t" is not defined,
evaluates to 0 [-Wundef]
9 | #define SIZE_MAX (~(size_t)0)
| ^~~~~~
../drivers/sbus/char/openprom.c:95:22: note: in expansion of macro
'SIZE_MAX'
95 | #if OPROMMAXPARAM > SIZE_MAX/2
| ^~~~~~~~
../include/linux/limits.h:9:28: error: missing binary operator before
token "0"
9 | #define SIZE_MAX (~(size_t)0)
| ^
../drivers/sbus/char/openprom.c:95:22: note: in expansion of macro
'SIZE_MAX'
95 | #if OPROMMAXPARAM > SIZE_MAX/2
| ^~~~~~~~
causing a build error.
--
~Randy
next prev parent reply other threads:[~2020-10-14 9:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 19:40 Michael Witten
2020-09-15 0:03 ` David Miller
2020-09-25 20:20 ` Michael Witten
2020-09-25 20:45 ` David Miller
2020-10-13 5:14 ` Randy Dunlap
2020-10-14 6:40 ` Randy Dunlap [this message]
2020-11-25 21:59 ` Randy Dunlap
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=c1329005-fa37-e02e-0105-2634ee566f55@infradead.org \
--to=rdunlap@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfwitten@gmail.com \
--cc=sparclinux@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®