2002-07-12 22:45:51

by Thunder from the hill

[permalink] [raw]
Subject: Compile warning in fs/partitions/check.c

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?

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);

Is it okay to ignore this one?

Regards,
Thunder
--
(Use http://www.ebb.org/ungeek if you can't decode)
------BEGIN GEEK CODE BLOCK------
Version: 3.12
GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$
N--- o? K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G
e++++ h* r--- y-
------END GEEK CODE BLOCK------


2002-07-12 23:02:59

by Thunder from the hill

[permalink] [raw]
Subject: Re: Compile warning in fs/partitions/check.c

Hi,

Possible fix for the show ones seems:

Index: include/linux/driverfs_fs.h
===================================================================
RCS file: /var/cvs/thunder-2.5/include/linux/driverfs_fs.h,v
retrieving revision 1.2
diff -p -u -r1.2 driverfs_fs.h
--- include/linux/driverfs_fs.h 9 Jul 2002 12:15:28 -0000 1.2
+++ include/linux/driverfs_fs.h 12 Jul 2002 23:04:08 -0000
@@ -41,8 +41,8 @@ struct driver_dir_entry {

struct device;

-typedef ssize_t (*driverfs_show)(void * obj, char * buf, size_t count, loff_t off);
-typedef ssize_t (*driverfs_store)(void * obj, const char * buf, size_t count, loff_t off);
+typedef ssize_t (*driverfs_show)(struct device * obj, char * buf, size_t count, loff_t off);
+typedef ssize_t (*driverfs_store)(struct device * obj, const char * buf, size_t count, loff_t off);

struct driver_file_entry {
struct driver_dir_entry * parent;

Not yet tested to compile, just on it...

Regards,
Thunder
--
(Use http://www.ebb.org/ungeek if you can't decode)
------BEGIN GEEK CODE BLOCK------
Version: 3.12
GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$
N--- o? K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G
e++++ h* r--- y-
------END GEEK CODE BLOCK------

2002-07-12 23:11:35

by Greg KH

[permalink] [raw]
Subject: Re: Compile warning in fs/partitions/check.c

On Fri, Jul 12, 2002 at 05:05:23PM -0600, Thunder from the hill wrote:
> Hi,
>
> Possible fix for the show ones seems:
>
> Index: include/linux/driverfs_fs.h
> ===================================================================
> RCS file: /var/cvs/thunder-2.5/include/linux/driverfs_fs.h,v
> retrieving revision 1.2
> diff -p -u -r1.2 driverfs_fs.h
> --- include/linux/driverfs_fs.h 9 Jul 2002 12:15:28 -0000 1.2
> +++ include/linux/driverfs_fs.h 12 Jul 2002 23:04:08 -0000
> @@ -41,8 +41,8 @@ struct driver_dir_entry {
>
> struct device;
>
> -typedef ssize_t (*driverfs_show)(void * obj, char * buf, size_t count, loff_t off);
> -typedef ssize_t (*driverfs_store)(void * obj, const char * buf, size_t count, loff_t off);
> +typedef ssize_t (*driverfs_show)(struct device * obj, char * buf, size_t count, loff_t off);
> +typedef ssize_t (*driverfs_store)(struct device * obj, const char * buf, size_t count, loff_t off);

No, this patch is incorrect. See Pat's patch that was posted a few
days ago.

And I don't think Richard really wants to be bothered with driverfs
questions :)

thanks,

greg k-h

2002-07-12 23:18:12

by Thunder from the hill

[permalink] [raw]
Subject: Re: Compile warning in fs/partitions/check.c

Hi,

> And I don't think Richard really wants to be bothered with driverfs
> questions :)

kernel oops at fs/partitions/check.c:-1!

Regards,
Thunder
--
(Use http://www.ebb.org/ungeek if you can't decode)
------BEGIN GEEK CODE BLOCK------
Version: 3.12
GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$
N--- o? K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G
e++++ h* r--- y-
------END GEEK CODE BLOCK------

2002-07-13 03:16:38

by Patrick Mochel

[permalink] [raw]
Subject: Re: Compile warning in fs/partitions/check.c


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

> Hi,
>
> > And I don't think Richard really wants to be bothered with driverfs
> > questions :)
>
> kernel oops at fs/partitions/check.c:-1!

Could you post the decoded output of the oops, and specify what patches
you have applied (and modified).

Thanks,

-pat

2002-07-13 03:15:26

by Patrick Mochel

[permalink] [raw]
Subject: Re: Compile warning in fs/partitions/check.c


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