summaryrefslogtreecommitdiff
path: root/.clang-tidy
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-04-13 02:40:40 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-04-15 22:23:02 +0300
commit1ad214dd1b353e79923ec6d6dfd4246759e99407 (patch)
tree230b68485c32562078b19730cd4348bf24210f42 /.clang-tidy
parentc244d07286e4010ee884eeea6f8e67fa5d1ff3cb (diff)
libcamera: span: Fix reverse iterators
std::reverse_iterator<iterator> is constructed from an instance of iterator, and automatically subtracts 1 when dereferencing. rbegin() and rend() should thus be constructed from end() and begin() respectively. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to '.clang-tidy')
0 files changed, 0 insertions, 0 deletions
id='n116' href='#n116'>116 117 118 119
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * event-thread.cpp - Threaded event test
 */

#include <chrono>
#include <iostream>
#include <string.h>
#include <unistd.h>

#include <libcamera/base/event_notifier.h>
#include <libcamera/base/thread.h>
#include <libcamera/base/timer.h>

#include "test.h"

using namespace std;
using namespace libcamera;

class EventHandler : public Object
{
public:
	EventHandler()
		: notified_(false)
	{
		int ret = pipe(pipefd_);
		if (ret < 0) {
			ret = errno;
			cout << "pipe() failed: " << strerror(ret) << endl;
		}

		notifier_ = new EventNotifier(pipefd_[0], EventNotifier::Read, this);
		notifier_->activated.connect(this, &EventHandler::readReady);
	}

	~EventHandler()
	{
		delete notifier_;

		close(pipefd_[0]);
		close(pipefd_[1]);
	}

	int notify()
	{
		std::string data("H2G2");
		ssize_t ret;

		memset(data_, 0, sizeof(data_));
		size_ = 0;

		ret = write(pipefd_[1], data.data(), data.size());
		if (ret < 0) {
			cout << "Pipe write failed" << endl;
			return TestFail;
		}

		return TestPass;
	}

	bool notified() const
	{
		return notified_;
	}

private:
	void readReady()
	{
		size_ = read(notifier_->fd(), data_, sizeof(data_));
		notified_ = true;
	}

	EventNotifier *notifier_;

	int pipefd_[2];

	bool notified_;
	char data_[16];
	ssize_t size_;
};

class EventThreadTest : public Test
{
protected: