[libcamera-devel] [PATCH] libcamera: event_dispatcher_poll: Simplify range iterator
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Jun 25 15:32:59 CEST 2019
Hi Kieran,
Thank you for the patch.
I would write the subject as "Fix compilation warning" or something
along those lines.
On Tue, Jun 25, 2019 at 02:15:08PM +0100, Kieran Bingham wrote:
> GCCv6 and GCCv7 take objections to declaring a struct type when
> using a range based iterator. This issue does not appear in GCCv8
>
> event_dispatcher_poll.cpp:231:13: error: types may not be defined
> in a for-range-declaration [-Werror]
>
> for (const struct pollfd &pfd : pollfds) {
> ^~~~~~
>
> cc1plus: all warnings being treated as errors
>
> Removing the keyword 'struct' ensures that the compiler does not try to
> declare the type, and instead uses the type as already defined by the
> relevant poll.h header.
I can't reproduce this with gcc 6.4.0 or 7.4.0, I wonder if it could be
related to the C library. You may want to mention the exact compiler
versions that resulted in the error.
In any case,
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> Reported-by: [autobuild.buildroot.net] Thomas Petazzoni <thomas.petazzoni at bootlin.com>
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
> src/libcamera/event_dispatcher_poll.cpp | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/libcamera/event_dispatcher_poll.cpp b/src/libcamera/event_dispatcher_poll.cpp
> index 0ff99fce47ab..df9dffb2326c 100644
> --- a/src/libcamera/event_dispatcher_poll.cpp
> +++ b/src/libcamera/event_dispatcher_poll.cpp
> @@ -241,7 +241,7 @@ void EventDispatcherPoll::processNotifiers(const std::vector<struct pollfd> &pol
> { EventNotifier::Exception, POLLPRI },
> };
>
> - for (const struct pollfd &pfd : pollfds) {
> + for (const pollfd &pfd : pollfds) {
> auto iter = notifiers_.find(pfd.fd);
> ASSERT(iter != notifiers_.end());
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list