Messages in this thread | | | Date | Thu, 30 May 2002 09:26:28 +0200 | From | Michael Dunsky <> | Subject | Re: 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/
| |