From: Eugeniu Rosca <roscaeugeniu@gmail.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
linux-i2c@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
Ulrich Hecht <uli+renesas@fpond.eu>,
Eugeniu Rosca <rosca.eugeniu@gmail.com>,
Eugeniu Rosca <erosca@de.adit-jv.com>
Subject: Re: [PATCH 1/2] i2c: rcar: refactor private flags
Date: Mon, 8 Oct 2018 13:30:47 +0200 [thread overview]
Message-ID: <20181008113047.GA31984@x230> (raw)
In-Reply-To: <20181005162728.ntzslfexkecbomkc@ninjato>
Hi Wolfram,
On Fri, Oct 05, 2018 at 06:27:28PM +0200, Wolfram Sang wrote:
>
> > May I ask how exactly you spotted the "shift-31-problem" in
> > drivers/i2c/busses/i2c-rcar.c:
> > - visual code review?
> > - static analysis, special compiler flags?
>
> This one. I run a set of static code analyziers when applying patches.
> One of them is 'cppcheck' which reported it.
Indeed, cppcheck reports w/o this patch:
[drivers/i2c/busses/i2c-rcar.c:972]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[drivers/i2c/busses/i2c-rcar.c:1008]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
>
> > According to feedback from GCC community [2], with 'gcc -std=gnu89',
> > shifting into (not past) the sign bit is "defined behavior" which is why
> > UBSAN doesn't report this as an issue in Linux kernel. That makes me
>
> I see. I guess it can be argued. Yet, BIT() solves other issues as well
> ('1' vs '1u'), so this was probably a reasonable move nonetheless, plus
> we are super-super-sure about the shifting now.
>
I agree. There is no doubt that avoiding/fixing shifting into the sign
bit makes the code more portable and will lessen the pain when
switching Kbuild to C99/C11 (if ever needed). I still have open
questions, but since they go beyond i2c framework and beyond kernel
itself (as said, they originate from porting UBSan to U-Boot), I will
discuss them elsewhere.
Thanks again for the reply.
Best regards,
Eugeniu.
next prev parent reply other threads:[~2018-10-08 18:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-08 7:59 [PATCH 0/2] i2c: rcar: implement STOP and REP_START according to docs Wolfram Sang
2018-08-08 7:59 ` [PATCH 1/2] i2c: rcar: refactor private flags Wolfram Sang
2018-08-16 17:15 ` Ulrich Hecht
2018-08-20 12:50 ` Wolfram Sang
2018-10-04 14:47 ` Eugeniu Rosca
2018-10-05 16:27 ` Wolfram Sang
2018-10-08 11:30 ` Eugeniu Rosca [this message]
2018-08-08 7:59 ` [PATCH 2/2] i2c: rcar: implement STOP and REP_START according to docs Wolfram Sang
2018-08-16 17:15 ` Ulrich Hecht
2018-08-20 8:58 ` Wolfram Sang
2018-08-20 12:50 ` Wolfram Sang
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=20181008113047.GA31984@x230 \
--to=roscaeugeniu@gmail.com \
--cc=erosca@de.adit-jv.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=rosca.eugeniu@gmail.com \
--cc=uli+renesas@fpond.eu \
--cc=wsa+renesas@sang-engineering.com \
--cc=wsa@the-dreams.de \
--cc=yoshihiro.shimoda.uh@renesas.com \
/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;
as well as URLs for NNTP newsgroup(s).