mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Christian Dietrich <christian.dietrich@informatik.uni-erlangen.de>
Cc: Sergei Shtylyov <sshtylyov@mvista.com>,
	"David S. Miller" <davem@davemloft.net>,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
	vamos-dev@lists.cs.fau.de
Subject: Re: [PATCH] ide: icside.c: fix printk format string compile warning
Date: Sat, 02 Jun 2012 14:26:17 -0700	[thread overview]
Message-ID: <1338672377.24148.6.camel@joe2Laptop> (raw)
In-Reply-To: <86hauw7jee.fsf_-_@gandalf.zerties.org>

On Thu, 2012-05-31 at 12:08 +0200, Christian Dietrich wrote:
> Peak datarate is never bigger than an integer, and can therefore, as
> suggested in the printk format string, casted to an integer.
> ---
>  drivers/ide/icside.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c
> index 83e5100..755ef6b 100644
> --- a/drivers/ide/icside.c
> +++ b/drivers/ide/icside.c
> @@ -271,9 +271,9 @@ static void icside_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
>  
>  	ide_set_drivedata(drive, (void *)cycle_time);
>  
> -	printk("%s: %s selected (peak %dMB/s)\n", drive->name,
> -		ide_xfer_verbose(xfer_mode),
> -		2000 / (unsigned long)ide_get_drivedata(drive));
> +	printk(KERN_INFO "%s: %s selected (peak %dMB/s)\n", drive->name,
> +	       ide_xfer_verbose(xfer_mode),
> +	       (int) (2000 / (unsigned long)ide_get_drivedata(drive)));

Why do an unsigned long int divide then cast
the result at all?  Why not just
do a divide without the cast?

Using ide_get_drivedata is rather odd too as it would be
more readable as without the set/get and just use:

	printk(KERN_IFNO "%s: %s selected (peak %luMB/s)\n",
	       drive->name, ide_xfer_verbose(xfer_mode),
	       2000UL / cycle_time);

	ide_set_drivedata(drive, (void *)cycle_time);

without the additional get.

Also, cycle_time _could_ be used uninitialized
if somehow an xfer_mode switch/case isn't reached.


  reply	other threads:[~2012-06-02 21:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-29 10:30 [PATCH] ide: icside.c: Fix compile with CONFIG_BLK_DEV_IDEDMA_ICS=n Christian Dietrich
2012-05-29 12:39 ` Sergei Shtylyov
2012-05-31 10:06   ` Christian Dietrich
2012-06-02 21:12     ` David Miller
2012-06-05 12:23       ` Christian Dietrich
2012-06-06 17:37         ` David Miller
2012-05-31 10:08   ` [PATCH] ide: icside.c: fix printk format string compile warning Christian Dietrich
2012-06-02 21:26     ` Joe Perches [this message]
2012-06-05 12:28       ` Christian Dietrich
2012-06-06 17:37         ` David Miller

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=1338672377.24148.6.camel@joe2Laptop \
    --to=joe@perches.com \
    --cc=christian.dietrich@informatik.uni-erlangen.de \
    --cc=davem@davemloft.net \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sshtylyov@mvista.com \
    --cc=vamos-dev@lists.cs.fau.de \
    /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

Powered by JetHome