lkml.org 
[lkml]   [2012]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] ide: icside.c: fix printk format string compile warning
    From
    Date
    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.



    \
     
     \ /
      Last update: 2012-06-02 23:41    [W:2.829 / U:0.168 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site