[librsvg: 2/5] Suppress clippy errors about casts to more strictly aligned types




commit cc9bc87f68fd6d25829d1d7db1ecc7e0af2a59d4
Author: Sven Neumann <sven svenfoo org>
Date:   Mon Aug 24 23:11:49 2020 +0200

    Suppress clippy errors about casts to more strictly aligned types
    
    These seem to be correct as long as stride is correct.

 rsvg_internals/src/surface_utils/mod.rs            | 2 ++
 rsvg_internals/src/surface_utils/shared_surface.rs | 3 +++
 2 files changed, 5 insertions(+)
---
diff --git a/rsvg_internals/src/surface_utils/mod.rs b/rsvg_internals/src/surface_utils/mod.rs
index 44667918..8bbc57d1 100644
--- a/rsvg_internals/src/surface_utils/mod.rs
+++ b/rsvg_internals/src/surface_utils/mod.rs
@@ -69,6 +69,8 @@ pub trait ImageSurfaceDataExt: DerefMut<Target = [u8]> {
     #[inline]
     fn set_pixel(&mut self, stride: usize, pixel: Pixel, x: u32, y: u32) {
         let value = pixel.to_u32();
+
+        #[allow(clippy::cast_ptr_alignment)]
         unsafe {
             *(&mut self[y as usize * stride + x as usize * 4] as *mut u8 as *mut u32) = value;
         }
diff --git a/rsvg_internals/src/surface_utils/shared_surface.rs 
b/rsvg_internals/src/surface_utils/shared_surface.rs
index 427fb795..e954c5ee 100644
--- a/rsvg_internals/src/surface_utils/shared_surface.rs
+++ b/rsvg_internals/src/surface_utils/shared_surface.rs
@@ -358,6 +358,7 @@ impl ImageSurface<Shared> {
         assert!(x < self.width as u32);
         assert!(y < self.height as u32);
 
+        #[allow(clippy::cast_ptr_alignment)]
         let value = unsafe {
             *(self
                 .data_ptr
@@ -373,6 +374,7 @@ impl ImageSurface<Shared> {
     pub fn get_pixel_by_offset(&self, offset: isize) -> Pixel {
         assert!(offset < self.stride as isize * self.height as isize);
 
+        #[allow(clippy::cast_ptr_alignment)]
         let value = unsafe { *(self.data_ptr.as_ptr().offset(offset) as *const u32) };
         Pixel::from_u32(value)
     }
@@ -723,6 +725,7 @@ impl ImageSurface<Shared> {
 
                     let value = pixel.to_u32();
 
+                    #[allow(clippy::cast_ptr_alignment)]
                     unsafe {
                         let ptr = self
                             .ptr


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]