Re: [PATCH rdma-next] RDMA: Provide safe ib_alloc_device() function

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

 



On Mon, 2019-01-28 at 17:20 +-0200, Leon Romanovsky wrote:
+AD4 On Mon, Jan 28, 2019 at 07:01:41AM -0800, Bart Van Assche wrote:
+AD4 +AD4 On 1/28/19 6:14 AM, Leon Romanovsky wrote:
+AD4 +AD4 +AD4 -struct ib+AF8-device +ACo-ib+AF8-alloc+AF8-device(size+AF8-t size)+ADs
+AD4 +AD4 +AD4 +-void +ACoAXw-ib+AF8-alloc+AF8-device(size+AF8-t size)+ADs
+AD4 +AD4 +AD4 +-+ACM-define ib+AF8-alloc+AF8-device(drv+AF8-struct, member)                                    +AFw
+AD4 +AD4 +AD4 +-	(BUILD+AF8-BUG+AF8-ON+AF8-ZERO(offsetof(struct drv+AF8-struct, member)) +-              +AFw
+AD4 +AD4 +AD4 +-	 BUILD+AF8-BUG+AF8-ON+AF8-ZERO(+ACEAXwBf-builtin+AF8-types+AF8-compatible+AF8-p(                      +AFw
+AD4 +AD4 +AD4 +-		 typeof(((struct drv+AF8-struct +ACo)NULL)-+AD4-member),                  +AFw
+AD4 +AD4 +AD4 +-		 struct ib+AF8-device)) +-                                          +AFw
+AD4 +AD4 +AD4 +-	 +AF8-ib+AF8-alloc+AF8-device(sizeof(struct drv+AF8-struct)))
+AD4 +AD4 +AD4 +-
+AD4 +AD4 
+AD4 +AD4 Hi Leon,
+AD4 +AD4 
+AD4 +AD4 Have you considered to use a comma expression and BUILD+AF8-BUG+AF8-ON() instead
+AD4 +AD4 of adding the BUILD+AF8-BUG+AF8-ON+AF8-ZERO() results to the +AF8-ib+AF8-alloc+AF8-device()
+AD4 +AD4 return value? I think that would result in slightly easier to read code
+AD4 +AD4 and also in code that reflects the intent better.
+AD4 
+AD4 I wanted to make sure that macro is used as assignment and returns
+AD4 value, in such case it should be art of expression, hence in success
+AD4 it is evaluated to 0.
+AD4 
+AD4 I will very happy to receive code snippet for the same with BUILD+AF8-BUG+AF8-ON().

Hi Leon,

How about the following macro definition, which uses BUILD+AF8-BUG+AF8-ON() instead of
BUILD+AF8-BUG+AF8-ON+AF8-ZERO() and which uses +AF8AXw-same+AF8-type() instead of
+AF8AXw-builtin+AF8-types+AF8-compatible+AF8-p() (compile-tested only):

+ACM-define ib+AF8-alloc+AF8-device(drv+AF8-struct, member)				+AFw
	((+AHs-BUILD+AF8-BUG+AF8-ON(offsetof(struct drv+AF8-struct, member) +ACEAPQ 0)+ADsAfQ),	+AFw
	 (+AHs-BUILD+AF8-BUG+AF8-ON(+ACEAXwBf-same+AF8-type(((struct drv+AF8-struct +ACo)NULL)-+AD4-member, +AFw
				     struct ib+AF8-device))+ADsAfQ),		+AFw
	 +AF8-ib+AF8-alloc+AF8-device(sizeof(struct drv+AF8-struct)))

Thanks,

Bart.



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux