From: Alexey Dobriyan <adobriyan@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
linux-kernel@vger.kernel.org, behlendorf1@llnl.gov
Subject: Re: [PATCH] remove abs64()
Date: Wed, 13 Apr 2011 23:36:08 +0300 [thread overview]
Message-ID: <20110413203608.GA4284@p183> (raw)
In-Reply-To: <20110413132629.6111f7f2.akpm@linux-foundation.org>
On Wed, Apr 13, 2011 at 01:26:29PM -0700, Andrew Morton wrote:
> On Wed, 13 Apr 2011 22:20:31 +0200
> Oleg Nesterov <oleg@redhat.com> wrote:
>
> > > > But, we have some stupid users which do something like abs(u32_value)
> > > > and expecting that abs() should treat this value as "signed".
> > > >
> > >
> > > um, yes, I'd forgotten that one. That's a show-stopper.
> >
> > May be we can demand to fix them?
> >
> > I agree with Alexey, it is a bit ugly to have abs() and abs64(), and abs()
> > itself doesn't look very nice.
> >
> > What if we simply add
> >
> > BUILD_BUG_ON( (typeof(_x)-1) > 0 );
> >
> > into abs()?
> >
> > After that it would be trivial to find the offenders and fix them,
> >
> > - abs(unsigned_int)
> > + abs((int) unsigned_int)
>
> Something like that. But it should be done before we change abs(), to
> avoid nasty breakage in obscure places.
>
> Or we rework the abs() implementation so that the abs(unsigned)
> behavior is unchanged.
>
> There will remain the problem that the abs() return value's signedness
> has changed.
Maybe I can sneak in kabs() ang gradually convert?
Reading abs(3) manpage, it returns int minumum, so semantic change
notice would be nice.
Anyway patch as posted was buggy in the following sense:
_b_t_c_p(char, signed char) == 0
AND
_b_t_c_p(char, unsigned char) == 0
so if char is signed, it doesn't work.
prev parent reply other threads:[~2011-04-13 20:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-12 21:00 [PATCH] remove abs64() Alexey Dobriyan
2011-04-12 21:07 ` Randy Dunlap
2011-04-12 21:10 ` Andrew Morton
2011-04-12 21:16 ` Alexey Dobriyan
2011-04-12 21:33 ` Andrew Morton
2011-04-12 21:40 ` Randy Dunlap
2011-04-12 21:14 ` Alexey Dobriyan
2011-04-13 14:27 ` Oleg Nesterov
2011-04-13 18:48 ` Andrew Morton
2011-04-13 20:20 ` Oleg Nesterov
2011-04-13 20:26 ` Andrew Morton
2011-04-13 20:36 ` Alexey Dobriyan [this message]
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=20110413203608.GA4284@p183 \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=behlendorf1@llnl.gov \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.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).