Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity



On Wed, Jul 30, 2008 at 10:18 AM, Andrew Morton
<akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
On Wed, 30 Jul 2008 10:10:06 +0200 Petr Tesarik <ptesarik@xxxxxxx> wrote:

Resent because of a typo in the LKML address. :(

Thanks.


Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667
still leaves a bug in the error message, because it uses the unconverted
big-endian value for printk.

Fix this by using a local variable in machine byte order. The result is
correct, more readable, and also produces slightly shorter code on i386.

Cc: Jens Axboe <jens.axboe@xxxxxxxxxx>
Cc: Jan Kara <jack@xxxxxxx>
Signed-off-by: Petr Tesarik <ptesarik@xxxxxxx>

I definitely like this one better, thanks.

Acked-by: Borislav Petkov <petkovbb@xxxxxxxxx>



Bart owns this patch now. It got lost for a month and it has already
been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x,
so it'll get complicated. Not a happy little patch.

Greg, can you please apply this one on top of -stable.



ide-cd.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1305,6 +1305,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
int stat;
unsigned char cmd[BLK_MAX_CDB];
unsigned len = sizeof(capbuf);
+ __u32 blocklen;

memset(cmd, 0, BLK_MAX_CDB);
cmd[0] = GPCMD_READ_CDVD_CAPACITY;
@@ -1317,23 +1318,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
/*
* Sanity check the given block size
*/
- switch (capbuf.blocklen) {
- case __constant_cpu_to_be32(512):
- case __constant_cpu_to_be32(1024):
- case __constant_cpu_to_be32(2048):
- case __constant_cpu_to_be32(4096):
+ blocklen = be32_to_cpu(capbuf.blocklen);
+ switch (blocklen) {
+ case 512:
+ case 1024:
+ case 2048:
+ case 4096:
break;
default:
printk(KERN_ERR "%s: weird block size %u\n",
- drive->name, capbuf.blocklen);
+ drive->name, blocklen);
printk(KERN_ERR "%s: default to 2kb block size\n",
drive->name);
- capbuf.blocklen = __constant_cpu_to_be32(2048);
+ blocklen = 2048;
break;
}

*capacity = 1 + be32_to_cpu(capbuf.lba);
- *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS;
+ *sectors_per_frame = blocklen >> SECTOR_BITS;
return 0;
}


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




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



Relevant Pages

  • Re: [Bug #10724] ACPI: EC: GPE storm detected, disabling EC GPE
    ... that sometimes gnome-power-manager is slow to respond when I switch to ... The following bug entry is on the current list of known regressions ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: acpi ->video_device_list corruption
    ... This resulted in silent corruption without ... The patch was seen to resolve the issue on the affected system. ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: [PATCH 1/4] Calgary: phb_shift can be int
    ... switch ) { ... If you carefully review code and see that there is absolutely no possibility of using an uninitialized variable in any execution path, then you can assign it to itself to quiet the compiler. ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: [BUG] e100: eth0 appers many times in /proc/interrupts after resume
    ... Could you try the following patch? ... I just fixed suspend/shutdown for e100 in 2.6.19, not sure why the problem still shows up. ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: [PATCH 03/11] VFS: Add security label support to *notify
    ... So this method will work on the server side and I will probably switch ... The only thing we get here is an iattr structure ... functionality provided by patch 1 we don't even know where to put the ... More majordomo info at http://vger.kernel.org/majordomo-info.html ...
    (Linux-Kernel)