All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] mtd: spi-nor: Check the return value from read_sr()
Date: Thu, 19 Nov 2015 14:58:11 -0800	[thread overview]
Message-ID: <20151119225811.GL64635@google.com> (raw)
In-Reply-To: <CAOMZO5ADJSW446A20wO+Hv-oY9vXjtP3nG0v6hBnAA=FT_-OqA@mail.gmail.com>

On Thu, Nov 19, 2015 at 08:48:23PM -0200, Fabio Estevam wrote:
> On Thu, Nov 19, 2015 at 7:54 PM, Brian Norris
> <computersforpeace@gmail.com> wrote:
> 
> > Hmm, by changing status_old from u8 to int, do we propagate any
> > sign-extension issues in this function? What if BIT(7) is set? If I
> 
> If the value returned by read_sr() has BIT(7) set then it is not an
> error, right?
> 
> read_sr() can return negative on error and u8 on success.
> 
> Not sure I understand your concern.

I guess my comment was based on my misplaced uncertainty on whether u8
would sign-extend or zero-extend when converted to int. It appears the
standard says that unsigned values get zero-extended. i.e.:

	u8 val = BIT(7); // 0x80

gets zero-extended to:

	return val; // that is, 0x00000080, not 0xffffff80

If we stick with u8, then it doesn't really matter which one it is.

The only remaining concern is over the mild awkwardness of comparing and
manipulating status_old and status_new, where one is int and the other
is u8. But I guess there are no issues yet, AFAICT.

Brian

  reply	other threads:[~2015-11-19 22:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17 14:50 [PATCH] mtd: spi-nor: Check the return value from read_sr() Fabio Estevam
2015-11-19 21:54 ` Brian Norris
2015-11-19 22:48   ` Fabio Estevam
2015-11-19 22:58     ` Brian Norris [this message]
2015-11-20 18:25       ` Fabio Estevam

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=20151119225811.GL64635@google.com \
    --to=computersforpeace@gmail.com \
    --cc=fabio.estevam@freescale.com \
    --cc=festevam@gmail.com \
    --cc=linux-mtd@lists.infradead.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 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.