Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1550120 > unrolled thread
| Started by | Paul Gortmaker <paul.gortmaker@windriver.com> |
|---|---|
| First post | 2017-01-03 20:40 +0100 |
| Last post | 2017-01-05 05:10 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] vfio-mdev: fix non-standard ioctl return val causing i386 build fail Paul Gortmaker <paul.gortmaker@windriver.com> - 2017-01-03 20:40 +0100
Re: [PATCH] vfio-mdev: fix non-standard ioctl return val causing i386 build fail Kirti Wankhede <kwankhede@nvidia.com> - 2017-01-04 13:40 +0100
Re: [PATCH] vfio-mdev: fix non-standard ioctl return val causing i386 build fail Alex Williamson <alex.williamson@redhat.com> - 2017-01-04 16:50 +0100
[PATCH v2] vfio-mdev: fix non-standard ioctl return val causing i386 build fail Paul Gortmaker <paul.gortmaker@windriver.com> - 2017-01-05 05:10 +0100
| From | Paul Gortmaker <paul.gortmaker@windriver.com> |
|---|---|
| Date | 2017-01-03 20:40 +0100 |
| Subject | [PATCH] vfio-mdev: fix non-standard ioctl return val causing i386 build fail |
| Message-ID | <sVD69-2ux-21@gated-at.bofh.it> |
What appears to be a copy and paste error from the line above gets
the ioctl a ssize_t return value instead of the traditional "int".
The associated sample code used "long" which meant it would compile
for x86-64 but not i386, with the latter failing as follows:
CC [M] samples/vfio-mdev/mtty.o
samples/vfio-mdev/mtty.c:1418:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.ioctl = mtty_ioctl,
^
samples/vfio-mdev/mtty.c:1418:20: note: (near initialization for ‘mdev_fops.ioctl’)
cc1: some warnings being treated as errors
Use the standard "int" ioctl return value in both the header and
the sample code to fix the issue.
Fixes: 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")
Cc: Kirti Wankhede <kwankhede@nvidia.com>
Cc: Neo Jia <cjia@nvidia.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
include/linux/mdev.h | 2 +-
samples/vfio-mdev/mtty.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/mdev.h b/include/linux/mdev.h
index 3ee44b8d2bb3..46659572ab00 100644
--- a/include/linux/mdev.h
+++ b/include/linux/mdev.h
@@ -78,7 +78,7 @@ struct mdev_parent_ops {
size_t count, loff_t *ppos);
ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
size_t count, loff_t *ppos);
- ssize_t (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
+ int (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
unsigned long arg);
int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
};
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 919c10d5b12e..6f0713b1f717 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -1147,7 +1147,7 @@ int mtty_get_device_info(struct mdev_device *mdev,
return 0;
}
-static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
+static int mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
unsigned long arg)
{
int ret = 0;
--
2.11.0
[toc] | [next] | [standalone]
| From | Kirti Wankhede <kwankhede@nvidia.com> |
|---|---|
| Date | 2017-01-04 13:40 +0100 |
| Subject | Re: [PATCH] vfio-mdev: fix non-standard ioctl return val causing i386 build fail |
| Message-ID | <sVT1f-4FT-7@gated-at.bofh.it> |
| In reply to | #1550120 |
Thanks Paul for catching this.
In that case we should go with 'long' since mdev_parent_ops->ioctl() is
called from vfio_device_ops->ioctl() for which the return type is 'long'.
Thanks,
Kirti
On 1/4/2017 1:06 AM, Paul Gortmaker wrote:
> What appears to be a copy and paste error from the line above gets
> the ioctl a ssize_t return value instead of the traditional "int".
>
> The associated sample code used "long" which meant it would compile
> for x86-64 but not i386, with the latter failing as follows:
>
> CC [M] samples/vfio-mdev/mtty.o
> samples/vfio-mdev/mtty.c:1418:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
> .ioctl = mtty_ioctl,
> ^
> samples/vfio-mdev/mtty.c:1418:20: note: (near initialization for ‘mdev_fops.ioctl’)
> cc1: some warnings being treated as errors
>
> Use the standard "int" ioctl return value in both the header and
> the sample code to fix the issue.
>
> Fixes: 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")
> Cc: Kirti Wankhede <kwankhede@nvidia.com>
> Cc: Neo Jia <cjia@nvidia.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: kvm@vger.kernel.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> ---
> include/linux/mdev.h | 2 +-
> samples/vfio-mdev/mtty.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mdev.h b/include/linux/mdev.h
> index 3ee44b8d2bb3..46659572ab00 100644
> --- a/include/linux/mdev.h
> +++ b/include/linux/mdev.h
> @@ -78,7 +78,7 @@ struct mdev_parent_ops {
> size_t count, loff_t *ppos);
> ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
> size_t count, loff_t *ppos);
> - ssize_t (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
> + int (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
> unsigned long arg);
> int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
> };
> diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
> index 919c10d5b12e..6f0713b1f717 100644
> --- a/samples/vfio-mdev/mtty.c
> +++ b/samples/vfio-mdev/mtty.c
> @@ -1147,7 +1147,7 @@ int mtty_get_device_info(struct mdev_device *mdev,
> return 0;
> }
>
> -static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
> +static int mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
> unsigned long arg)
> {
> int ret = 0;
>
[toc] | [prev] | [next] | [standalone]
| From | Alex Williamson <alex.williamson@redhat.com> |
|---|---|
| Date | 2017-01-04 16:50 +0100 |
| Subject | Re: [PATCH] vfio-mdev: fix non-standard ioctl return val causing i386 build fail |
| Message-ID | <sVVZ7-6Ac-7@gated-at.bofh.it> |
| In reply to | #1550724 |
On Wed, 4 Jan 2017 18:06:57 +0530
Kirti Wankhede <kwankhede@nvidia.com> wrote:
> Thanks Paul for catching this.
>
> In that case we should go with 'long' since mdev_parent_ops->ioctl() is
> called from vfio_device_ops->ioctl() for which the return type is 'long'.
Agreed, we're mirroring the struct file_operations definition of ioctl,
so the return should be a long. Thanks,
Alex
> On 1/4/2017 1:06 AM, Paul Gortmaker wrote:
> > What appears to be a copy and paste error from the line above gets
> > the ioctl a ssize_t return value instead of the traditional "int".
> >
> > The associated sample code used "long" which meant it would compile
> > for x86-64 but not i386, with the latter failing as follows:
> >
> > CC [M] samples/vfio-mdev/mtty.o
> > samples/vfio-mdev/mtty.c:1418:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
> > .ioctl = mtty_ioctl,
> > ^
> > samples/vfio-mdev/mtty.c:1418:20: note: (near initialization for ‘mdev_fops.ioctl’)
> > cc1: some warnings being treated as errors
> >
> > Use the standard "int" ioctl return value in both the header and
> > the sample code to fix the issue.
> >
> > Fixes: 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")
> > Cc: Kirti Wankhede <kwankhede@nvidia.com>
> > Cc: Neo Jia <cjia@nvidia.com>
> > Cc: Alex Williamson <alex.williamson@redhat.com>
> > Cc: kvm@vger.kernel.org
> > Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> > ---
> > include/linux/mdev.h | 2 +-
> > samples/vfio-mdev/mtty.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/mdev.h b/include/linux/mdev.h
> > index 3ee44b8d2bb3..46659572ab00 100644
> > --- a/include/linux/mdev.h
> > +++ b/include/linux/mdev.h
> > @@ -78,7 +78,7 @@ struct mdev_parent_ops {
> > size_t count, loff_t *ppos);
> > ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
> > size_t count, loff_t *ppos);
> > - ssize_t (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
> > + int (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
> > unsigned long arg);
> > int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
> > };
> > diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
> > index 919c10d5b12e..6f0713b1f717 100644
> > --- a/samples/vfio-mdev/mtty.c
> > +++ b/samples/vfio-mdev/mtty.c
> > @@ -1147,7 +1147,7 @@ int mtty_get_device_info(struct mdev_device *mdev,
> > return 0;
> > }
> >
> > -static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
> > +static int mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
> > unsigned long arg)
> > {
> > int ret = 0;
> >
[toc] | [prev] | [next] | [standalone]
| From | Paul Gortmaker <paul.gortmaker@windriver.com> |
|---|---|
| Date | 2017-01-05 05:10 +0100 |
| Subject | [PATCH v2] vfio-mdev: fix non-standard ioctl return val causing i386 build fail |
| Message-ID | <sW7xf-60g-9@gated-at.bofh.it> |
| In reply to | #1550939 |
What appears to be a copy and paste error from the line above gets
the ioctl a ssize_t return value instead of the traditional "int".
The associated sample code used "long" which meant it would compile
for x86-64 but not i386, with the latter failing as follows:
CC [M] samples/vfio-mdev/mtty.o
samples/vfio-mdev/mtty.c:1418:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.ioctl = mtty_ioctl,
^
samples/vfio-mdev/mtty.c:1418:20: note: (near initialization for ‘mdev_fops.ioctl’)
cc1: some warnings being treated as errors
Since in this case, vfio is working with struct file_operations; as such:
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
...and so here we just standardize on long vs. the normal int that user
space typically sees and documents as per "man ioctl" and similar.
Fixes: 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")
Cc: Kirti Wankhede <kwankhede@nvidia.com>
Cc: Neo Jia <cjia@nvidia.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
[v1 --> v2: promote ioctl return from int to long to align with the
struct file_operations as per requests in review comments. ]
include/linux/mdev.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/mdev.h b/include/linux/mdev.h
index 3ee44b8d2bb3..b6e048e1045f 100644
--- a/include/linux/mdev.h
+++ b/include/linux/mdev.h
@@ -78,7 +78,7 @@ struct mdev_parent_ops {
size_t count, loff_t *ppos);
ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
size_t count, loff_t *ppos);
- ssize_t (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
+ long (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
unsigned long arg);
int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
};
--
2.11.0
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web