public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Adrian Bunk <bunk@kernel.org>
Cc: Paul Menage <menage@google.com>,
	Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
	Paul Jackson <pj@sgi.com>, Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix cpuset sched_relax_domain_level control file
Date: Wed, 7 May 2008 08:08:22 -0700	[thread overview]
Message-ID: <20080507080822.212174f2.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080507094809.GB29935@cs181133002.pp.htv.fi>

On Wed, 7 May 2008 12:48:09 +0300 Adrian Bunk <bunk@kernel.org> wrote:

> On Tue, May 06, 2008 at 06:41:39PM -0700, Paul Menage wrote:
> > On Tue, May 6, 2008 at 6:38 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
> > > On Tue, 06 May 2008 18:08:17 -0700 Paul Menage <menage@google.com> wrote:
> > >
> > >  > -static int update_relax_domain_level(struct cpuset *cs, char *buf)
> > >  > +static int update_relax_domain_level(struct cpuset *cs, s64 val)
> > >  >  {
> > >  > -     int val = simple_strtol(buf, NULL, 10);
> > >  > -
> > >  > -     if (val < 0)
> > >  > +     if ((int)val < 0)
> > >  >               val = -1;
> > >  >
> > >
> > >  Are you sure about the typecast here?  If `val' has a value of say
> > >  0x0000_ffff_ffff_ffff then I assume the casted value will be negative, only
> > >  it wasn't?
> > 
> > It seems like the simplest approach - if it's outside the range of a
> > positive int, set it to -1.
> 
> That's very hard to understand for someone who looks at the code - and 
> being able to understand the code is much more important than the 
> number of characters in the source code.
> 
> If you'd write something like
> 
>   if ((val < 0) || (val > INT_MAX))
> 
> instead it would be obvious for the reader what's happening here, and 
> that this was intended.

What he said.


Our poor reader now knows what was intended.  But he still doesn't know _why_
it was intended.


  reply	other threads:[~2008-05-07 15:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-07  1:08 [PATCH] Fix cpuset sched_relax_domain_level control file Paul Menage
2008-05-07  1:21 ` Li Zefan
2008-05-07  1:31 ` Andrew Morton
2008-05-07  1:40   ` Paul Jackson
2008-05-07  3:38     ` Reverting per-cpuset "system" (IRQ affinity) patch (was: Fix cpuset sched_relax_domain_level control file) Paul Jackson
2008-05-07  3:44       ` Andrew Morton
2008-05-07  3:52         ` Paul Jackson
2008-05-07  6:44           ` Peter Zijlstra
2008-05-08 17:56             ` Reverting per-cpuset "system" (IRQ affinity) patch Max Krasnyansky
2008-05-09 10:22               ` Ingo Molnar
2008-05-09 11:26                 ` Paul Jackson
2008-05-21  0:46                   ` Max Krasnyanskiy
2008-05-07  1:38 ` [PATCH] Fix cpuset sched_relax_domain_level control file Andrew Morton
2008-05-07  1:41   ` Paul Menage
2008-05-07  9:48     ` Adrian Bunk
2008-05-07 15:08       ` Andrew Morton [this message]
2008-05-07  1:46   ` Li Zefan
2008-05-07  1:49     ` Paul Jackson
2008-05-07  1:51       ` Paul Menage
2008-05-07  1:58         ` Paul Jackson
2008-05-07  2:08           ` Andrew Morton
2008-05-07  2:11             ` Paul Jackson
2008-05-07  2:15               ` Paul Menage
2008-05-07  2:28                 ` Andrew Morton
2008-05-07  2:32                 ` Paul Jackson
2008-05-07  2:12           ` Li Zefan
2008-05-07  2:17             ` Paul Jackson
2008-05-07  2:27             ` Hidetoshi Seto

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=20080507080822.212174f2.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=bunk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menage@google.com \
    --cc=mingo@elte.hu \
    --cc=pj@sgi.com \
    --cc=seto.hidetoshi@jp.fujitsu.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