public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Dunsky <michael.dunsky@p4all.de>
To: linux-kernel@vger.kernel.org
Cc: Peter Chubb <peter@chubb.wattle.id.au>
Subject: Re: Strange code in ide_cdrom_register
Date: Thu, 30 May 2002 09:26:28 +0200	[thread overview]
Message-ID: <3CF5D424.2060500@p4all.de> (raw)
In-Reply-To: <15605.34861.599803.405864@wombat.chubb.wattle.id.au>

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



  reply	other threads:[~2002-05-30  7:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-30  2:02 Strange code in ide_cdrom_register Peter Chubb
2002-05-30  7:26 ` Michael Dunsky [this message]
2002-05-30  9:05   ` Peter Chubb
2002-05-30 10:35     ` J.A. Magallon
2002-05-30 20:19     ` Michael Dunsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3CF5D424.2060500@p4all.de \
    --to=michael.dunsky@p4all.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@chubb.wattle.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox