From 9a716604fcbb5638d0a1e6c527bad8776fc07a4e Mon Sep 17 00:00:00 2001
From: 4lDO2 <4lDO2@protonmail.com>
Date: Sun, 20 Dec 2020 16:36:52 +0100
Subject: [PATCH] Implement Copy and Clone manually for BuddyEntry.
This fixes a warning that may in the future become an error, about the
possibility for unaligned references, since the derive macros apparently
rely on creating references to fields. Unaligned references are direct
UB.
---
src/allocator/frame/buddy.rs | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/allocator/frame/buddy.rs b/src/allocator/frame/buddy.rs
index 3e371b3091..16240ec883 100644
--- a/src/allocator/frame/buddy.rs
+++ b/src/allocator/frame/buddy.rs
@@ -16,7 +16,6 @@ use crate::{
#[repr(transparent)]
struct BuddyUsage(u8);
-#[derive(Clone, Copy)]
#[repr(packed)]
struct BuddyEntry {
base: PhysicalAddress,
@@ -28,6 +27,19 @@ struct BuddyEntry {
phantom: PhantomData,
}
+impl Clone for BuddyEntry {
+ fn clone(&self) -> Self {
+ Self {
+ base: self.base,
+ size: self.size,
+ skip: self.skip,
+ used: self.used,
+ phantom: PhantomData,
+ }
+ }
+}
+impl Copy for BuddyEntry {}
+
impl BuddyEntry {
fn empty() -> Self {
Self {