* [PATCH] v4l2-compliance: fix function pointer prototype
@ 2014-04-01 13:45 Lad, Prabhakar
2014-04-01 13:50 ` Hans Verkuil
0 siblings, 1 reply; 6+ messages in thread
From: Lad, Prabhakar @ 2014-04-01 13:45 UTC (permalink / raw)
To: LMML, Hans Verkuil; +Cc: Lad Prabhakar
From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
There was a conflict between the mmap function pointer prototype of
struct v4l_fd and the actual function used. Make sure it is in sync
with the prototype of v4l2_mmap.
This patch fixes following build error,
v4l2-compliance.cpp: In function 'void v4l_fd_test_init(v4l_fd*, int)':
v4l2-compliance.cpp:132: error: invalid conversion from
'void* (*)(void*, size_t, int, int, int, int64_t)' to
'void* (*)(void*, size_t, int, int, int, off_t)'
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
---
utils/v4l2-compliance/v4l-helpers.h | 2 +-
utils/v4l2-compliance/v4l2-compliance.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/utils/v4l2-compliance/v4l-helpers.h b/utils/v4l2-compliance/v4l-helpers.h
index 48ea602..b2ce6c0 100644
--- a/utils/v4l2-compliance/v4l-helpers.h
+++ b/utils/v4l2-compliance/v4l-helpers.h
@@ -10,7 +10,7 @@ struct v4l_fd {
int fd;
int (*ioctl)(int fd, unsigned long cmd, ...);
void *(*mmap)(void *addr, size_t length, int prot, int flags,
- int fd, int64_t offset);
+ int fd, off_t offset);
int (*munmap)(void *addr, size_t length);
};
diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h
index f2f7072..b6d4dae 100644
--- a/utils/v4l2-compliance/v4l2-compliance.h
+++ b/utils/v4l2-compliance/v4l2-compliance.h
@@ -137,7 +137,7 @@ static inline int test_ioctl(int fd, unsigned long cmd, ...)
}
static inline void *test_mmap(void *start, size_t length, int prot, int flags,
- int fd, int64_t offset)
+ int fd, off_t offset)
{
return wrapper ? v4l2_mmap(start, length, prot, flags, fd, offset) :
mmap(start, length, prot, flags, fd, offset);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] v4l2-compliance: fix function pointer prototype
2014-04-01 13:45 [PATCH] v4l2-compliance: fix function pointer prototype Lad, Prabhakar
@ 2014-04-01 13:50 ` Hans Verkuil
2014-04-01 14:06 ` Prabhakar Lad
0 siblings, 1 reply; 6+ messages in thread
From: Hans Verkuil @ 2014-04-01 13:50 UTC (permalink / raw)
To: Lad, Prabhakar; +Cc: LMML, Hans Verkuil
Hi Prabhakar,
On 04/01/14 15:45, Lad, Prabhakar wrote:
> From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
>
> There was a conflict between the mmap function pointer prototype of
> struct v4l_fd and the actual function used. Make sure it is in sync
> with the prototype of v4l2_mmap.
The prototype of v4l2_mmap uses int64_t, so I don't understand this
patch.
Regards,
Hans
>
> This patch fixes following build error,
>
> v4l2-compliance.cpp: In function 'void v4l_fd_test_init(v4l_fd*, int)':
> v4l2-compliance.cpp:132: error: invalid conversion from
> 'void* (*)(void*, size_t, int, int, int, int64_t)' to
> 'void* (*)(void*, size_t, int, int, int, off_t)'
>
> Cc: Hans Verkuil <hans.verkuil@cisco.com>
> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> ---
> utils/v4l2-compliance/v4l-helpers.h | 2 +-
> utils/v4l2-compliance/v4l2-compliance.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/utils/v4l2-compliance/v4l-helpers.h b/utils/v4l2-compliance/v4l-helpers.h
> index 48ea602..b2ce6c0 100644
> --- a/utils/v4l2-compliance/v4l-helpers.h
> +++ b/utils/v4l2-compliance/v4l-helpers.h
> @@ -10,7 +10,7 @@ struct v4l_fd {
> int fd;
> int (*ioctl)(int fd, unsigned long cmd, ...);
> void *(*mmap)(void *addr, size_t length, int prot, int flags,
> - int fd, int64_t offset);
> + int fd, off_t offset);
> int (*munmap)(void *addr, size_t length);
> };
>
> diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h
> index f2f7072..b6d4dae 100644
> --- a/utils/v4l2-compliance/v4l2-compliance.h
> +++ b/utils/v4l2-compliance/v4l2-compliance.h
> @@ -137,7 +137,7 @@ static inline int test_ioctl(int fd, unsigned long cmd, ...)
> }
>
> static inline void *test_mmap(void *start, size_t length, int prot, int flags,
> - int fd, int64_t offset)
> + int fd, off_t offset)
> {
> return wrapper ? v4l2_mmap(start, length, prot, flags, fd, offset) :
> mmap(start, length, prot, flags, fd, offset);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] v4l2-compliance: fix function pointer prototype
2014-04-01 13:50 ` Hans Verkuil
@ 2014-04-01 14:06 ` Prabhakar Lad
2014-04-01 14:26 ` Hans Verkuil
0 siblings, 1 reply; 6+ messages in thread
From: Prabhakar Lad @ 2014-04-01 14:06 UTC (permalink / raw)
To: Hans Verkuil; +Cc: LMML, Hans Verkuil
Hi Hans,
On Tue, Apr 1, 2014 at 7:20 PM, Hans Verkuil <hansverk@cisco.com> wrote:
> Hi Prabhakar,
>
> On 04/01/14 15:45, Lad, Prabhakar wrote:
>> From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
>>
>> There was a conflict between the mmap function pointer prototype of
>> struct v4l_fd and the actual function used. Make sure it is in sync
>> with the prototype of v4l2_mmap.
>
> The prototype of v4l2_mmap uses int64_t, so I don't understand this
> patch.
>
Actual prototype of mmap is,
void *mmap(void *addr, size_t length, int prot, int flags, int fd,
off_t offset);
But where as the prototype in v4l_fd mmap the last parameter type is int64_t
but that should have been off_t and same applies with test_mmap().
Thanks,
--Prabhakar Lad
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] v4l2-compliance: fix function pointer prototype
2014-04-01 14:06 ` Prabhakar Lad
@ 2014-04-01 14:26 ` Hans Verkuil
2014-04-01 14:42 ` Hans Verkuil
0 siblings, 1 reply; 6+ messages in thread
From: Hans Verkuil @ 2014-04-01 14:26 UTC (permalink / raw)
To: Prabhakar Lad; +Cc: LMML, Hans Verkuil
On 04/01/14 16:06, Prabhakar Lad wrote:
> Hi Hans,
>
> On Tue, Apr 1, 2014 at 7:20 PM, Hans Verkuil <hansverk@cisco.com> wrote:
>> Hi Prabhakar,
>>
>> On 04/01/14 15:45, Lad, Prabhakar wrote:
>>> From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
>>>
>>> There was a conflict between the mmap function pointer prototype of
>>> struct v4l_fd and the actual function used. Make sure it is in sync
>>> with the prototype of v4l2_mmap.
>>
>> The prototype of v4l2_mmap uses int64_t, so I don't understand this
>> patch.
>>
> Actual prototype of mmap is,
>
> void *mmap(void *addr, size_t length, int prot, int flags, int fd,
> off_t offset);
>
> But where as the prototype in v4l_fd mmap the last parameter type is int64_t
> but that should have been off_t and same applies with test_mmap().
The problem is that v4l2_mmap (in lib/include/libv4l2.h) uses int64_t.
So the function pointer uses int64_t as well as does test_mmap.
I don't see how the current v4l-utils tree can cause a compile error.
For the record, I know you can't assign mmap to fd->mmap, you would
have to make a wrapper. Unfortunately mmap and v4l2_mmap do not have
the same prototype and I had to pick one (I'm not sure why they don't
use the same prototype).
Most applications would typically have to use v4l2_mmap, so I went with
that one.
Regards,
Hans
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] v4l2-compliance: fix function pointer prototype
2014-04-01 14:26 ` Hans Verkuil
@ 2014-04-01 14:42 ` Hans Verkuil
2014-04-01 14:48 ` Prabhakar Lad
0 siblings, 1 reply; 6+ messages in thread
From: Hans Verkuil @ 2014-04-01 14:42 UTC (permalink / raw)
To: Hans Verkuil; +Cc: Prabhakar Lad, LMML, Hans Verkuil
On 04/01/14 16:26, Hans Verkuil wrote:
>
>
> On 04/01/14 16:06, Prabhakar Lad wrote:
>> Hi Hans,
>>
>> On Tue, Apr 1, 2014 at 7:20 PM, Hans Verkuil <hansverk@cisco.com> wrote:
>>> Hi Prabhakar,
>>>
>>> On 04/01/14 15:45, Lad, Prabhakar wrote:
>>>> From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
>>>>
>>>> There was a conflict between the mmap function pointer prototype of
>>>> struct v4l_fd and the actual function used. Make sure it is in sync
>>>> with the prototype of v4l2_mmap.
>>>
>>> The prototype of v4l2_mmap uses int64_t, so I don't understand this
>>> patch.
>>>
>> Actual prototype of mmap is,
>>
>> void *mmap(void *addr, size_t length, int prot, int flags, int fd,
>> off_t offset);
>>
>> But where as the prototype in v4l_fd mmap the last parameter type is int64_t
>> but that should have been off_t and same applies with test_mmap().
>
> The problem is that v4l2_mmap (in lib/include/libv4l2.h) uses int64_t.
> So the function pointer uses int64_t as well as does test_mmap.
>
> I don't see how the current v4l-utils tree can cause a compile error.
>
> For the record, I know you can't assign mmap to fd->mmap, you would
> have to make a wrapper. Unfortunately mmap and v4l2_mmap do not have
> the same prototype and I had to pick one (I'm not sure why they don't
> use the same prototype).
>
> Most applications would typically have to use v4l2_mmap, so I went with
> that one.
>
I missed that mmap is assigned to v4l_fd_init(). Since mmap and v4l2_mmap
have different prototypes the only solution is to make a wrapper.
Does this work?
diff --git a/utils/v4l2-compliance/v4l-helpers.h b/utils/v4l2-compliance/v4l-helpers.h
index 48ea602..e718a24 100644
--- a/utils/v4l2-compliance/v4l-helpers.h
+++ b/utils/v4l2-compliance/v4l-helpers.h
@@ -14,11 +14,21 @@ struct v4l_fd {
int (*munmap)(void *addr, size_t length);
};
+/*
+ * mmap has a different prototype compared to v4l2_mmap. Because of
+ * this we have to make a wrapper for it.
+ */
+static inline void *v4l_fd_mmap(void *addr, size_t length, int prot, int flags,
+ int fd, int64_t offset)
+{
+ return mmap(addr, length, prot, flags, fd, offset);
+}
+
static inline void v4l_fd_init(struct v4l_fd *f, int fd)
{
f->fd = fd;
f->ioctl = ioctl;
- f->mmap = mmap;
+ f->mmap = v4l_fd_mmap;
f->munmap = munmap;
}
On a 64-bit system the types are the same, it's only on a 32-bit system that
this will fail.
Regards,
Hans
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] v4l2-compliance: fix function pointer prototype
2014-04-01 14:42 ` Hans Verkuil
@ 2014-04-01 14:48 ` Prabhakar Lad
0 siblings, 0 replies; 6+ messages in thread
From: Prabhakar Lad @ 2014-04-01 14:48 UTC (permalink / raw)
To: Hans Verkuil; +Cc: Hans Verkuil, LMML, Hans Verkuil
Hi Hans,
On Tue, Apr 1, 2014 at 8:12 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> On 04/01/14 16:26, Hans Verkuil wrote:
>>
>>
>> On 04/01/14 16:06, Prabhakar Lad wrote:
>>> Hi Hans,
>>>
>>> On Tue, Apr 1, 2014 at 7:20 PM, Hans Verkuil <hansverk@cisco.com> wrote:
>>>> Hi Prabhakar,
>>>>
>>>> On 04/01/14 15:45, Lad, Prabhakar wrote:
>>>>> From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
>>>>>
>>>>> There was a conflict between the mmap function pointer prototype of
>>>>> struct v4l_fd and the actual function used. Make sure it is in sync
>>>>> with the prototype of v4l2_mmap.
>>>>
>>>> The prototype of v4l2_mmap uses int64_t, so I don't understand this
>>>> patch.
>>>>
>>> Actual prototype of mmap is,
>>>
>>> void *mmap(void *addr, size_t length, int prot, int flags, int fd,
>>> off_t offset);
>>>
>>> But where as the prototype in v4l_fd mmap the last parameter type is int64_t
>>> but that should have been off_t and same applies with test_mmap().
>>
>> The problem is that v4l2_mmap (in lib/include/libv4l2.h) uses int64_t.
>> So the function pointer uses int64_t as well as does test_mmap.
>>
>> I don't see how the current v4l-utils tree can cause a compile error.
>>
>> For the record, I know you can't assign mmap to fd->mmap, you would
>> have to make a wrapper. Unfortunately mmap and v4l2_mmap do not have
>> the same prototype and I had to pick one (I'm not sure why they don't
>> use the same prototype).
>>
>> Most applications would typically have to use v4l2_mmap, so I went with
>> that one.
>>
>
> I missed that mmap is assigned to v4l_fd_init(). Since mmap and v4l2_mmap
> have different prototypes the only solution is to make a wrapper.
>
> Does this work?
>
Yes it compiles now with the below patch.
Thanks,
--Prabhakar Lad
> diff --git a/utils/v4l2-compliance/v4l-helpers.h b/utils/v4l2-compliance/v4l-helpers.h
> index 48ea602..e718a24 100644
> --- a/utils/v4l2-compliance/v4l-helpers.h
> +++ b/utils/v4l2-compliance/v4l-helpers.h
> @@ -14,11 +14,21 @@ struct v4l_fd {
> int (*munmap)(void *addr, size_t length);
> };
>
> +/*
> + * mmap has a different prototype compared to v4l2_mmap. Because of
> + * this we have to make a wrapper for it.
> + */
> +static inline void *v4l_fd_mmap(void *addr, size_t length, int prot, int flags,
> + int fd, int64_t offset)
> +{
> + return mmap(addr, length, prot, flags, fd, offset);
> +}
> +
> static inline void v4l_fd_init(struct v4l_fd *f, int fd)
> {
> f->fd = fd;
> f->ioctl = ioctl;
> - f->mmap = mmap;
> + f->mmap = v4l_fd_mmap;
> f->munmap = munmap;
> }
>
>
> On a 64-bit system the types are the same, it's only on a 32-bit system that
> this will fail.
>
> Regards,
>
> Hans
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-04-01 14:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-01 13:45 [PATCH] v4l2-compliance: fix function pointer prototype Lad, Prabhakar
2014-04-01 13:50 ` Hans Verkuil
2014-04-01 14:06 ` Prabhakar Lad
2014-04-01 14:26 ` Hans Verkuil
2014-04-01 14:42 ` Hans Verkuil
2014-04-01 14:48 ` Prabhakar Lad
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).