diff --git a/sommelier-inpututils.cc b/sommelier-inpututils.cc index 1e00ab6..b5706e4 100644 --- a/sommelier-inpututils.cc +++ b/sommelier-inpututils.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "sommelier.h" // NOLINT(build/include_directory) -#include "sommelier-transform.h" // NOLINT(build/include_directory) -#include "sommelier-inpututils.h" +#include "sommelier.h" // NOLINT(build/include_directory) +#include "sommelier-inpututils.h" // NOLINT(build/include_directory) +#include "sommelier-transform.h" // NOLINT(build/include_directory) #include #include diff --git a/sommelier-inpututils.h b/sommelier-inpututils.h index 8be5403..dfd011c 100644 --- a/sommelier-inpututils.h +++ b/sommelier-inpututils.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef VM_TOOLS_SOMMELIER_SOMMELIER_INPUTUTIL_H_ -#define VM_TOOLS_SOMMELIER_SOMMELIER_INPUTUTIL_H_ +#ifndef VM_TOOLS_SOMMELIER_SOMMELIER_INPUTUTILS_H_ +#define VM_TOOLS_SOMMELIER_SOMMELIER_INPUTUTILS_H_ #include #include @@ -48,4 +48,4 @@ void sl_touchrecorder_replay_to_listener(struct sl_touchrecorder* recorder, void* data); void sl_touchrecorder_purge_id(struct sl_touchrecorder* recorder, int32_t id); -#endif // VM_TOOLS_SOMMELIER_SOMMELIER_INPUTUTIL_H_ +#endif // VM_TOOLS_SOMMELIER_SOMMELIER_INPUTUTILS_H_ diff --git a/sommelier-seat.cc b/sommelier-seat.cc index c38c3ba..3a056ca 100644 --- a/sommelier-seat.cc +++ b/sommelier-seat.cc @@ -3,9 +3,9 @@ // found in the LICENSE file. #include "sommelier.h" // NOLINT(build/include_directory) -#include "sommelier-transform.h" // NOLINT(build/include_directory) #include "sommelier-inpututils.h" // NOLINT(build/include_directory) #include "sommelier-stylus-tablet.h" // NOLINT(build/include_directory) +#include "sommelier-transform.h" // NOLINT(build/include_directory) #include #include diff --git a/sommelier.cc b/sommelier.cc index afd6084..0da9f38 100644 --- a/sommelier.cc +++ b/sommelier.cc @@ -3573,7 +3573,7 @@ int sl_run_parent(int argc, rv = sigaction(SIGCHLD, &sa, nullptr); errno_assert(rv >= 0); - do { + while (true) { struct ucred ucred; socklen_t length = sizeof(addr); @@ -3635,7 +3635,7 @@ int sl_run_parent(int argc, _exit(EXIT_FAILURE); } close(client_fd); - } while (1); + } // Control should never reach here. assert(false); @@ -4127,7 +4127,7 @@ int real_main(int argc, char** argv) { wl_client_add_destroy_listener(ctx.client, &client_destroy_listener); - do { + while (true) { wl_display_flush_clients(ctx.host_display); if (ctx.connection) { if (ctx.needs_set_input_focus) { @@ -4144,7 +4144,7 @@ int real_main(int argc, char** argv) { if (errno != EINTR) return EXIT_FAILURE; } - } while (1); + } return EXIT_SUCCESS; } // NOLINT(readability/fn_size) diff --git a/testing/mock-wayland-channel.h b/testing/mock-wayland-channel.h index 1d67fb1..0cc6b75 100644 --- a/testing/mock-wayland-channel.h +++ b/testing/mock-wayland-channel.h @@ -27,7 +27,7 @@ using ::testing::PrintToString; // Mock of Sommelier's Wayland connection to the host compositor. class MockWaylandChannel : public WaylandChannel { public: - MockWaylandChannel() {} + MockWaylandChannel() = default; MOCK_METHOD(int32_t, init, (), (override)); MOCK_METHOD(bool, supports_dmabuf, (), (override)); @@ -67,7 +67,7 @@ class MockWaylandChannel : public WaylandChannel { MOCK_METHOD(size_t, max_send_size, (), (override)); protected: - ~MockWaylandChannel() override {} + ~MockWaylandChannel() override = default; }; // Match a WaylandSendReceive buffer containing exactly one Wayland message diff --git a/testing/x11-test-base.h b/testing/x11-test-base.h index b30649f..fadbf9c 100644 --- a/testing/x11-test-base.h +++ b/testing/x11-test-base.h @@ -100,7 +100,7 @@ class X11DirectScaleTest : public X11TestBase { public: void InitContext() override { X11TestBase::InitContext(); - ctx.use_direct_scale = 1; + ctx.use_direct_scale = true; } void Connect() override { diff --git a/virtualization/virtgpu_channel.cc b/virtualization/virtgpu_channel.cc index 0f10fe1..e7c53e5 100644 --- a/virtualization/virtgpu_channel.cc +++ b/virtualization/virtgpu_channel.cc @@ -4,19 +4,19 @@ #include #include +#include #include #include #include #include #include -#include #include #include #include -#include "virtgpu_cross_domain_protocol.h" // NOLINT(build/include_directory) #include "linux-headers/virtgpu_drm.h" // NOLINT(build/include_directory) +#include "virtgpu_cross_domain_protocol.h" // NOLINT(build/include_directory) #include "wayland_channel.h" // NOLINT(build/include_directory) // The size of a page for the guest kernel @@ -150,11 +150,11 @@ int32_t VirtGpuChannel::init() { PARAM(VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs), }; - for (uint32_t i = 0; i < REQUIRED_PARAMS_SIZE; i++) { + for (const auto& param : params) { struct drm_virtgpu_getparam get_param = {0}; - get_param.param = params[i].param; - get_param.value = (uint64_t)(uintptr_t)¶ms[i].value; + get_param.param = param.param; + get_param.value = (uint64_t)(uintptr_t)¶m.value; ret = drmIoctl(virtgpu_, DRM_IOCTL_VIRTGPU_GETPARAM, &get_param); if (ret < 0) { fprintf(stderr, "DRM_IOCTL_VIRTGPU_GET_PARAM failed with %s\n", @@ -164,15 +164,15 @@ int32_t VirtGpuChannel::init() { return -EINVAL; } - if (params[i].param == VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs) { - if ((params[i].value & (1 << CAPSET_CROSS_DOMAIN)) == 0) + if (param.param == VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs) { + if ((param.value & (1 << CAPSET_CROSS_DOMAIN)) == 0) return -ENOTSUP; } } args.cap_set_id = CAPSET_CROSS_DOMAIN; args.size = sizeof(struct CrossDomainCapabilities); - args.addr = (unsigned long long)&cross_domain_caps; + args.addr = (uint64_t)&cross_domain_caps; ret = drmIoctl(virtgpu_, DRM_IOCTL_VIRTGPU_GET_CAPS, &args); if (ret) { @@ -195,7 +195,7 @@ int32_t VirtGpuChannel::init() { return 0; } -bool VirtGpuChannel::supports_dmabuf(void) { +bool VirtGpuChannel::supports_dmabuf() { return supports_dmabuf_; } @@ -216,7 +216,7 @@ int32_t VirtGpuChannel::create_context(int& out_channel_fd) { ctx_set_params[2].param = VIRTGPU_CONTEXT_PARAM_POLL_RINGS_MASK; ctx_set_params[2].value = 1 << CROSS_DOMAIN_CHANNEL_RING; - init.ctx_set_params = (unsigned long long)&ctx_set_params[0]; + init.ctx_set_params = (uint64_t)&ctx_set_params[0]; init.num_params = 3; ret = drmIoctl(virtgpu_, DRM_IOCTL_VIRTGPU_CONTEXT_INIT, &init); if (ret) { @@ -248,8 +248,8 @@ int32_t VirtGpuChannel::create_context(int& out_channel_fd) { return ret; } - ring_addr_ = mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, virtgpu_, - map.offset); + ring_addr_ = mmap(nullptr, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, + virtgpu_, map.offset); if (ring_addr_ == MAP_FAILED) { fprintf(stderr, "mmap failed with %s\n", strerror(errno)); @@ -568,7 +568,7 @@ int32_t VirtGpuChannel::close_gem_handle(uint32_t gem_handle) { return 0; } -int32_t VirtGpuChannel::channel_poll(void) { +int32_t VirtGpuChannel::channel_poll() { int32_t ret; struct CrossDomainPoll cmd_poll = {{0}}; @@ -834,6 +834,6 @@ int32_t VirtGpuChannel::pipe_lookup(uint32_t identifier_type, return -EINVAL; } -size_t VirtGpuChannel::max_send_size(void) { +size_t VirtGpuChannel::max_send_size() { return MAX_SEND_SIZE; } diff --git a/virtualization/virtgpu_cross_domain_protocol.h b/virtualization/virtgpu_cross_domain_protocol.h index 34fb827..aa5b42e 100644 --- a/virtualization/virtgpu_cross_domain_protocol.h +++ b/virtualization/virtgpu_cross_domain_protocol.h @@ -108,4 +108,4 @@ struct CrossDomainReadWrite { uint32_t pad; }; -#endif +#endif // VM_TOOLS_SOMMELIER_VIRTUALIZATION_VIRTGPU_CROSS_DOMAIN_PROTOCOL_H_ diff --git a/virtualization/virtwl_channel.cc b/virtualization/virtwl_channel.cc index 8e52b62..ece7e74 100644 --- a/virtualization/virtwl_channel.cc +++ b/virtualization/virtwl_channel.cc @@ -53,7 +53,7 @@ int32_t VirtWaylandChannel::init() { return 0; } -bool VirtWaylandChannel::supports_dmabuf(void) { +bool VirtWaylandChannel::supports_dmabuf() { return supports_dmabuf_; } @@ -220,6 +220,6 @@ int32_t VirtWaylandChannel::handle_pipe(int read_fd, return 0; } -size_t VirtWaylandChannel::max_send_size(void) { +size_t VirtWaylandChannel::max_send_size() { return MAX_SEND_SIZE; } diff --git a/virtualization/wayland_channel.h b/virtualization/wayland_channel.h index d6df1cf..819af8e 100644 --- a/virtualization/wayland_channel.h +++ b/virtualization/wayland_channel.h @@ -75,8 +75,8 @@ struct WaylandBufferCreateOutput { class WaylandChannel { public: - WaylandChannel() {} - virtual ~WaylandChannel() {} + WaylandChannel() = default; + virtual ~WaylandChannel() = default; // Initializes the Wayland Channel. Returns 0 on success, -errno on failure. virtual int32_t init() = 0; @@ -84,7 +84,7 @@ class WaylandChannel { // Returns true if the Wayland channel supports dmabuf, false otherwise. If // dmabuf is supported, Sommelier will use the `zwp_linux_dmabuf_v1` // protocol. - virtual bool supports_dmabuf(void) = 0; + virtual bool supports_dmabuf() = 0; // Creates a new context for handling the wayland command stream. Returns 0 // on success, and a pollable `out_channel_fd`. This fd represents the @@ -159,13 +159,13 @@ class WaylandChannel { // Returns the maximum size of opaque data that the channel is able to handle // in the `send` function. Must be less than or equal to DEFAULT_BUFFER_SIZE. - virtual size_t max_send_size(void) = 0; + virtual size_t max_send_size() = 0; }; class VirtWaylandChannel : public WaylandChannel { public: VirtWaylandChannel() : virtwl_{-1}, supports_dmabuf_(false) {} - ~VirtWaylandChannel(); + ~VirtWaylandChannel() override; int32_t init() override; bool supports_dmabuf() override; @@ -181,7 +181,7 @@ class VirtWaylandChannel : public WaylandChannel { int32_t sync(int dmabuf_fd, uint64_t flags) override; int32_t handle_pipe(int read_fd, bool readable, bool& hang_up) override; - size_t max_send_size(void) override; + size_t max_send_size() override; private: // virtwl device file descriptor @@ -197,7 +197,7 @@ class VirtGpuChannel : public WaylandChannel { ring_handle_{0}, supports_dmabuf_(false), descriptor_id_{1} {} - ~VirtGpuChannel(); + ~VirtGpuChannel() override; int32_t init() override; bool supports_dmabuf() override; @@ -213,7 +213,7 @@ class VirtGpuChannel : public WaylandChannel { int32_t sync(int dmabuf_fd, uint64_t flags) override; int32_t handle_pipe(int read_fd, bool readable, bool& hang_up) override; - size_t max_send_size(void) override; + size_t max_send_size() override; private: /* @@ -246,7 +246,7 @@ class VirtGpuChannel : public WaylandChannel { uint32_t size, uint32_t ring_idx, bool wait); - int32_t channel_poll(void); + int32_t channel_poll(); int32_t close_gem_handle(uint32_t gem_handle); int32_t create_host_blob(uint64_t blob_id, uint64_t size, int& out_fd); @@ -265,7 +265,7 @@ class VirtGpuChannel : public WaylandChannel { struct WaylandSendReceive& receive, int& out_read_pipe); - int32_t handle_read(void); + int32_t handle_read(); int32_t pipe_lookup(uint32_t identifier_type, uint32_t& identifier,