mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Phillip Potter' <phil@philpotter.co.uk>,
	"dushistov@mail.ru" <dushistov@mail.ru>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: RE: [PATCH] fs: ufs: Remove switch statement from ufs_set_de_type function
Date: Wed, 17 Oct 2018 10:11:47 +0000	[thread overview]
Message-ID: <fc2004614b7e4a35a67eb93a007a60f8@AcuMS.aculab.com> (raw)
In-Reply-To: <20181017100809.GA9070@pathfinder>

From: Phillip Potter
> Sent: 17 October 2018 11:08
> 
> Remove switch statement from ufs_set_de_type function in fs/ufs/util.h
> header and replace with simple assignment. For each case, S_IFx >> 12
> is equal to DT_x, so in valid cases (mode & S_IFMT) >> 12 should give
> us the correct file type. For invalid cases, upper layer validation
> catches this anyway, so this improves readability and arguably
> performance by assigning (mode & S_IFMT) >> 12 directly.
> 
...
> -	case S_IFIFO:
> -		de->d_u.d_44.d_type = DT_FIFO;
> -		break;
> -	default:
> -		de->d_u.d_44.d_type = DT_UNKNOWN;
> -	}
> +	de->d_u.d_44.d_type = (mode & S_IFMT) >> S_SHIFT;

This requires that the two sets of constants are correctly aligned.
If they aren't defined in terms of each other then you probably
ought to add compile-time asserts that the values match.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


  reply	other threads:[~2018-10-17 10:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-17 10:08 Phillip Potter
2018-10-17 10:11 ` David Laight [this message]
2018-10-17 23:33   ` Al Viro
2018-10-18 10:19     ` Phillip Potter
  -- strict thread matches above, loose matches on Subject: below --
2018-10-20 22:09 Phillip Potter
2018-10-20 22:26 ` Matthew Wilcox
2018-10-20 23:07   ` Al Viro
2018-10-21  5:30   ` Amir Goldstein
2018-10-21  9:57     ` Phillip Potter
2018-10-21 11:02       ` Amir Goldstein
2018-10-22  8:20         ` Phillip Potter
2018-10-17 12:34 Phillip Potter
2018-10-09 13:16 Phillip Potter
2018-10-02 16:41 Phillip Potter

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=fc2004614b7e4a35a67eb93a007a60f8@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=dushistov@mail.ru \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phil@philpotter.co.uk \
    /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

Powered by JetHome