From: Alex Markuze Date: Mon, 7 Apr 2025 19:57:20 +0000 (+0000) Subject: array handling X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=54b3ca2459ecfe1f6ff16351f21a5a99b1ac8971;p=ceph-client.git array handling --- diff --git a/include/linux/ceph/ceph_san_ser.h b/include/linux/ceph/ceph_san_ser.h index aa6f688bc2045..7f6e491e079f4 100644 --- a/include/linux/ceph/ceph_san_ser.h +++ b/include/linux/ceph/ceph_san_ser.h @@ -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, \ @@ -88,6 +88,20 @@ (*(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))