linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Christopher Friesen" <cfriesen@nortelnetworks.com>
To: Herbert Rosmanith <herp@wildsau.idv-edu.uni-linz.ac.at>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [IDEA+RFC] Possible solution for min()/max() war -- I like this
Date: Wed, 29 Aug 2001 16:07:10 -0400	[thread overview]
Message-ID: <3B8D4B6E.331966E0@nortelnetworks.com> (raw)
In-Reply-To: <200108291911.f7TJBvX11490@wildsau.idv-edu.uni-linz.ac.at>

Herbert Rosmanith wrote:

> #define type_min(type,x,y) \
>         ({ type __x = (x), __y = (y); __x < __y ? __x: __y; })
> #define type_max(type,x,y) \
>         ({ type __x = (x), __y = (y); __x > __y ? __x: __y; })
> 
> #define min(x,y) type_min(typeof(x),x,y)
> #define max(x,y) type_max(typeof(x),x,y)
> 
> no _implicit_ cast and ...
> 
> > One of the arguments gets changed invisibly, and that is what kernel
> > developers are so upset about.  You don't really know which one without
> > thinking hard about it, and that is a source of many hard-to-find bugs.
> 
> ... joy, we would even know which one.

I think this makes a lot of sense.  The explicit version could be preferred, but
for the implicit version we at least know that what type will be used for it and
it won't immediately break things that are still using the old-style min/max.


-- 
Chris Friesen                    | MailStop: 043/33/F10  
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com

      reply	other threads:[~2001-08-29 20:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200108291905.f7TJ59T11456@wildsau.idv-edu.uni-linz.ac.at>
2001-08-29 19:11 ` [IDEA+RFC] Possible solution for min()/max() war Herbert Rosmanith
2001-08-29 20:07   ` Christopher Friesen [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=3B8D4B6E.331966E0@nortelnetworks.com \
    --to=cfriesen@nortelnetworks.com \
    --cc=herp@wildsau.idv-edu.uni-linz.ac.at \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).