Re: Compile warning in fs/partitions/check.c

From: Patrick Mochel (mochel@osdl.org)
Date: Fri Jul 12 2002 - 22:16:02 EST


On Fri, 12 Jul 2002, Thunder from the hill wrote:

> Hi,
>
> Compiling fs/partitions/check.c, I get a couple of warnings of "pointer to
> integer of different size":
>
>
> kdev is a kdev_t here, driverfs_dev is a struct device.
>
> kdev.value=(int)driverfs_dev->driver_data;
>
> Is it okay to replace this with
>
> kdev.value=(unsigned short)driverfs_dev->driver_data;
>
> to make the warnings go away?

This code definitely shouldn't rely on the format of the kdev_t structure.
It looks like it should be something like:

- kdev.value=(int)driverfs_dev->driver_data;
- return off ? 0 : sprintf (page, "%x\n",kdev.value);
+ kdev = val_to_kdev((int)driverfs_dev->driver_data);
+ return off ? 0 : sprintf (page, "%x\n",kdev_val(kdev));

> Also, struct driver_file_entry->show gets initialized here:
>
> show: partition_device_kdev_read,
>
> show being (ssize_t *)(struct device *driverfs_dev, char *page, size_t
> count, loff_t off);
> but expecting (ssize_t *)(void *, char *page, size_t count, loff_t off);

First off, you might want to specify that you are using a specific patch.
The change of the first parameter of the show() and store() callbacks was
in a patch I posted last week. As of a few seconds ago, it hadn't been
merged into Linus' kernel.org tree.

Second, the definition of the callbacks should change, and there should be
an appropriate cast in the function. I have patches for all the users of
those callbacks, but I'm waiting until I finally resolve the refcounting
issues and post and updated patch to post those. FWIW, the pointer passed
to those callbacks is guaranteed to be a struct device, so the warning is,
for now, harmless.

Finally, if you have driverfs questions/problems/concerns, please copy me
(and not Richard). :)

        -pat

-
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/



This archive was generated by hypermail 2b29 : Mon Jul 15 2002 - 22:00:25 EST