From 4c64fa7c6fd946f9cdd07a932bbee504593cb952 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 18 Jun 2020 14:34:28 -0700 Subject: [PATCH] io_uring: allow alignment-changing casts of mmap uring.rs wraps the kernel io_uring interfaces that provide C-style raw pointers, which requires casting a *u8 into other types with stricter alignment requirements. All of these casts are based on the base mmap() pointer (which is always page aligned) or offsets within an mmap provided by the kernel, so we can assume they are safe to cast to the relevant more-aligned types. Fixes clippy warnings of the form: casting from `*mut u8` to a more-strictly-aligned pointer (`*const std::sync::atomic::AtomicU32`) (1 < 4 bytes) BUG=None TEST=bin/clippy Change-Id: Ibef32bb8529d34ece79f089992ad8bd880c5030b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2253068 Reviewed-by: Dylan Reid Tested-by: kokoro Tested-by: Daniel Verkamp Commit-Queue: Daniel Verkamp --- io_uring/src/uring.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/io_uring/src/uring.rs b/io_uring/src/uring.rs index 2a78753d06..dd56bd56ca 100644 --- a/io_uring/src/uring.rs +++ b/io_uring/src/uring.rs @@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// This file makes several casts from u8 pointers into more-aligned pointer types. +// We assume that the kernel will give us suitably aligned memory. +#![allow(clippy::cast_ptr_alignment)] + use std::collections::BTreeMap; use std::fmt; use std::fs::File;