From: Harvey Harrison <harvey.harrison@gmail.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] ata: use clamp_t macro to avoid sparse warnings
Date: Wed, 20 Feb 2008 09:36:36 -0800 [thread overview]
Message-ID: <1203528996.25307.2.camel@brick> (raw)
In-Reply-To: <47BC6073.8080705@garzik.org>
Nesting min_t/max_t macros produces many shadowed variable warnings
due to use of __x. Add a clamp_t macro to linux/kernel.h and use
it in the FIT macro.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
include/linux/kernel.h | 9 +++++++++
include/linux/libata.h | 2 +-
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2df44e7..47924ce 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -362,6 +362,15 @@ static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char *
#define max_t(type,x,y) \
({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
+/*
+ * Clamp a value to within a given range using comparisons of a specified type.
+ */
+#define clamp_t(type,val,min,max) ({ \
+ type __val = (val); \
+ type __min = (min); \
+ type __max = (max); \
+ __val = __val < __min ? __min: __val; \
+ __val > __max ? __max: __val; })
/**
* container_of - cast a member of a structure out to the containing structure
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 2e098f9..8adc2a0 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -754,7 +754,7 @@ struct ata_timing {
unsigned short udma; /* t2CYCTYP/2 */
};
-#define FIT(v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin)
+#define FIT(v, vmin, vmax) clamp_t(short, v, vmin, vmax)
extern const unsigned long sata_deb_timing_normal[];
extern const unsigned long sata_deb_timing_hotplug[];
--
1.5.4.2.200.g99e75
prev parent reply other threads:[~2008-02-20 17:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-18 16:07 [PATCH] ata: replace macro with static inline in libata.h Harvey Harrison
2008-02-20 17:16 ` Jeff Garzik
2008-02-20 17:36 ` Harvey Harrison [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=1203528996.25307.2.camel@brick \
--to=harvey.harrison@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=jeff@garzik.org \
--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