lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9ea470500804170212md8ce430p42b3c1787ba95631@mail.gmail.com>
Date:	Thu, 17 Apr 2008 11:12:30 +0200
From:	"Boris Petkov" <petkovbb@...glemail.com>
To:	"Roel Kluin" <12o3l@...cali.nl>
Cc:	"Bartlomiej Zolnierkiewicz" <bzolnier@...il.com>,
	linux-ide@...r.kernel.org, lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/6] IDE: ide-cd: fix test unsigned var < 0

On Thu, Apr 17, 2008 at 5:51 AM, Roel Kluin <12o3l@...cali.nl> wrote:
> Bartlomiej Zolnierkiewicz wrote:
>  > Hi,
>  >
>  > On Wednesday 16 April 2008, Roel Kluin wrote:
>  >> Is this the right fix in this case?
>  >
>  > Yes, but it seems that 'valid' is only written to
>  > so it may be as well removed completely.
>  >
>  > Care to update the patch?
>  >
>  > Thanks,
>  > Bart
>
>  how about this?
>
>  Roel
>
>  ---
>  Clean up cdrom_analyze_sense_data()
>
>
>  Signed-off-by: Roel Kluin <12o3l@...cali.nl>
>  ---
>  diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
>  index a60f5df..a5f3beb 100644
>
> --- a/drivers/ide/ide-cd.c
>  +++ b/drivers/ide/ide-cd.c
>  @@ -143,8 +143,6 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
>                               struct request_sense *sense)
>   {
>         unsigned long sector;
>  -       unsigned long bio_sectors;
>  -       unsigned long valid;
>         struct cdrom_info *info = drive->driver_data;
>
>         if (!cdrom_log_sense(drive, failed_command, sense))
>  @@ -174,13 +172,9 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
>                                  (sense->information[2] <<  8) |
>                                  (sense->information[3]);
>
>  -                       bio_sectors = bio_sectors(failed_command->bio);
>  -                       if (bio_sectors < 4)
>  -                               bio_sectors = 4;
>                         if (drive->queue->hardsect_size == 2048)
>                                 sector <<= 2;   /* Device sector size is 2K */
>  -                       sector &= ~(bio_sectors -1);
>
> -                       valid = (sector - failed_command->sector) << 9;
>  +                       sector &= ~(max(bio_sectors(failed_command->bio) - 1, 3));

Well, i don't think that this "optimization" makes the code more readable.
Besides, gcc does this anyway. Poor are only those who have to stare at it for
a couple of minutes just to understand what it says. Still, i don't object to
it completely and the "valid"-var can go. I'd rather keep the "unsigned long
bio_sectors;" part and do something of the likes of:

bio_sectors = bio_sectors(failed_command->bio);


(remove the "if (bio_sectors < 4)"-test)

... and later...

sector &= ~(max(bio_sectors - 1, 3));

which is, IMO, more readable.

Roel, would you redo your patch please? Thanks.

-- 
Regards/Gruß,
Boris
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ