]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commitdiff
array handling
authorAlex Markuze <amarkuze@redhat.com>
Mon, 7 Apr 2025 19:57:20 +0000 (19:57 +0000)
committerAlex Markuze <amarkuze@redhat.com>
Mon, 7 Apr 2025 19:57:20 +0000 (19:57 +0000)
include/linux/ceph/ceph_san_ser.h

index aa6f688bc2045325a418082ab8aace0fa85afbb0..7f6e491e079f46e48f92e5fb58ec2c5281dbe3b1 100644 (file)
@@ -76,7 +76,7 @@
     ((type)(value)) \
     _Pragma("GCC diagnostic pop")
 
-#define __ceph_san_ser_type(__buffer, __t)                     \
+#define __ceph_san_ser_type_no_arr(__buffer, __t)                     \
     (__builtin_choose_expr(sizeof(__t) == 1,                   \
         (*(uint8_t *)(__buffer) = __suppress_cast_warning(uint8_t, __t)),  \
     __builtin_choose_expr(sizeof(__t) == 2,                    \
         (*(typeof(__t) *)(__buffer) = __suppress_cast_warning(typeof(__t), __t)) \
     )))))
 
+#define __ceph_san_ser_type(__buffer, __t)                          \
+    (__builtin_choose_expr(__builtin_classify_type(__t) == 14,      \
+        memcpy((__buffer), __suppress_cast_warning(void *, __t), sizeof(__t)),                     \
+    __builtin_choose_expr(sizeof(__t) == 1,                         \
+        (*(uint8_t *)(__buffer) = __suppress_cast_warning(uint8_t, __t)),  \
+    __builtin_choose_expr(sizeof(__t) == 2,                         \
+        (*(uint16_t *)(__buffer) = __suppress_cast_warning(uint16_t, __t)), \
+    __builtin_choose_expr(sizeof(__t) == 4,                         \
+        (*(uint32_t *)(__buffer) = __suppress_cast_warning(uint32_t, __t)), \
+    __builtin_choose_expr(sizeof(__t) == 8,                         \
+        (*(uint64_t *)(__buffer) = __suppress_cast_warning(uint64_t, __t)), \
+        (*(typeof(__t) *)(__buffer) = __suppress_cast_warning(typeof(__t), __t)) \
+    ))))))
+
 #define __ceph_san_ser(__buffer, __t) (__ceph_san_ser_type(__buffer, __t), __buffer = (void*)((typeof(__t)*)__buffer + 1))
 #define ___ceph_san_ser0(__buffer)
 #define ___ceph_san_ser1(__buffer, __t)                (__ceph_san_ser(__buffer, __t))