lkml.org 
[lkml]   [2002]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Strange code in ide_cdrom_register
Hi!

Peter Chubb wrote:
> Hi,
> This code snippet in ide_cdrom_register() seems really
> strange...
>
> devinfo->ops = &ide_cdrom_dops;
> devinfo->mask = 0;
>
>>>> *(int *)&devinfo->speed = CDROM_STATE_FLAGS (drive)->current_speed;
>>>> *(int *)&devinfo->capacity = nslots;
>>>
> devinfo->handle = (void *) drive;
> strcpy(devinfo->name, drive->name);
>
> devinfo->speed and devinfo->capacity are both ints. So the casts are
> just a disaster waiting to happen, if the types of capacity or speed
> ever change?

Just take a quick look in drivers/ide/ide-cd.h: values "nslots" and
"current_speed" are of type "byte", so we need to cast to store them
(like that) into the integer-vars. Nothing strange there....


> Peter C
>

ciao

Michael


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

\
 
 \ /
  Last update: 2005-03-22 13:26    [W:4.020 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site