mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] userns: simplify map_id_range_* functions
Date: Sun, 26 Jul 2015 23:29:16 -0500	[thread overview]
Message-ID: <878ua26x5v.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <1437875432-15502-1-git-send-email-nicolas.iooss_linux@m4x.org> (Nicolas Iooss's message of "Sun, 26 Jul 2015 09:50:32 +0800")

Nicolas Iooss <nicolas.iooss_linux@m4x.org> writes:

> Functions map_id_range_down, map_id_down and map_id_up all used the
> construction:
>
>     if (...)
>         id = ...
>     else
>         id = ...
>     return id;
>
> which can be simplified by directly returning the result of the
> computations in each branch.
>
> Moreover as the condition tested whether the "break;" in the previous
> for loop was hit, it is simpler to directly compute the result and
> return it.

It is not a simplification, it is just code motion.

Further at least to my eyes adding multiple exit points and setting the
same value in two different places actually obscures what the functions
are doing.

If we could talk about speeding up the performance of the stat system
call I think there would be a point in mucking with these functions.

As it is I think it is I think merging your patch will just make it more
difficult to understand what the code is doing in the future, with no 
benefit except a reduction in line count.

Eric

  reply	other threads:[~2015-07-27  4:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-26  1:50 Nicolas Iooss
2015-07-27  4:29 ` Eric W. Biederman [this message]
2015-07-27 12:59   ` Nicolas Iooss
2015-07-27 18:04     ` Eric W. Biederman

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=878ua26x5v.fsf@x220.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=nicolas.iooss_linux@m4x.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®