From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: jaxboe@fusionio.com, James.Bottomley@hansenpartnership.com,
christof.schmitt@de.ibm.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/2] Consolidate min_not_zero
Date: Fri, 10 Sep 2010 15:20:39 +0200 [thread overview]
Message-ID: <201009101520.47005.eike-kernel@sf-tec.de> (raw)
In-Reply-To: <1284096730-13147-2-git-send-email-martin.petersen@oracle.com>
[-- Attachment #1: Type: Text/Plain, Size: 820 bytes --]
Martin K. Petersen wrote:
> We have several users of min_not_zero, each of them using their own
> definition. Move the define to kernel.h.
For whatever reason this one hit my inbox way later than the previous one.
Anyone, the same concern:
> +/*
> + * Returns the minimum that is _not_ zero, unless both are zero.
> + */
> +#define min_not_zero(__x, __y) ({ \
> + __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
> +
This will evaluate the value of __x and __y multiple times. Something like
this should be better (untested):
define min_not_zero(__x, __y) ({ \
typeof(__x) _minz1 = (__x); \
typeof(__y) _minz2 = (__y); \
_minz1 == 0 ? _minz2 : ((_minz2 == 0) ? _minz1 : min(_minz1, _minz2));
})
Eike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2010-09-10 13:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-10 5:32 Limit number of integrity segments Martin K. Petersen
2010-09-10 5:32 ` [PATCH 1/2] Consolidate min_not_zero Martin K. Petersen
2010-09-10 13:20 ` Rolf Eike Beer [this message]
2010-09-10 5:32 ` [PATCH 2/2] block/scsi: Provide a limit on the number of integrity segments Martin K. Petersen
2010-09-10 11:45 ` [PATCH] zfcp: Report scatter gather limit for DIX protection information Christof Schmitt
2010-09-10 12:04 ` Limit number of integrity segments Jens Axboe
2010-09-10 12:41 ` Martin K. Petersen
2010-09-10 12:52 ` Christof Schmitt
2010-09-10 13:01 ` Jens Axboe
2010-09-10 13:17 ` Christof Schmitt
2010-09-10 13:40 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2010-09-10 5:18 (unknown), Martin K. Petersen
2010-09-10 5:18 ` [PATCH 1/2] Consolidate min_not_zero Martin K. Petersen
2010-09-10 8:13 ` Rolf Eike Beer
2010-09-10 16:13 ` Martin K. Petersen
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=201009101520.47005.eike-kernel@sf-tec.de \
--to=eike-kernel@sf-tec.de \
--cc=James.Bottomley@hansenpartnership.com \
--cc=christof.schmitt@de.ibm.com \
--cc=jaxboe@fusionio.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.