All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harvey Harrison <harvey.harrison@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Bernd Petrovitsch <bernd@firmix.at>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] char: hide sparse expensive pointer subtraction warning in specialix.c
Date: Fri, 22 Feb 2008 10:51:05 -0800	[thread overview]
Message-ID: <1203706265.5962.30.camel@brick> (raw)
In-Reply-To: <1203705247.5962.17.camel@brick>

The warnings come from two static inlines so the ugliness in hiding them
is well contained.
drivers/char/specialix.c:238:19: warning: potentially expensive pointer subtraction
drivers/char/specialix.c:245:19: warning: potentially expensive pointer subtraction

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
Bernd noticed that I'm an idiot.  I was only hiding them to see what else
was in the file.  This patch is at least functionally correct.

Brown-paper-bagged-by: Harvey Harrison

 drivers/char/specialix.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index c0e08c7..34c7de6 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -228,21 +228,21 @@ static inline int sx_paranoia_check(struct specialix_port const * port,
 /* Get board number from pointer */
 static inline int board_No (struct specialix_board * bp)
 {
-	return bp - sx_board;
+	return ((char *)bp - (char *)sx_board) / sizeof(*bp);
 }
 
 
 /* Get port number from pointer */
 static inline int port_No (struct specialix_port const * port)
 {
-	return SX_PORT(port - sx_port);
+	return SX_PORT(((char *)port - (char *)sx_port) / sizeof(*port));
 }
 
 
 /* Get pointer to board from pointer to port */
 static inline struct specialix_board * port_Board(struct specialix_port const * port)
 {
-	return &sx_board[SX_BOARD(port - sx_port)];
+	return &sx_board[SX_BOARD(port_No(port))];
 }
 
 
-- 
1.5.4.2.200.g99e75



  reply	other threads:[~2008-02-22 18:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-22 18:34 [PATCH 1/2] char: hide sparse expensive pointer subtraction warning in specialix.c Harvey Harrison
2008-02-22 18:51 ` Harvey Harrison [this message]
2008-02-22 19:13 ` Joe Perches

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=1203706265.5962.30.camel@brick \
    --to=harvey.harrison@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bernd@firmix.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 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.