Re: [PATCH 2/3] c/r: Add CR_COPY() macro (v3)

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

 



Hi Dan.

Dan Smith <danms@xxxxxxxxxx> wrote:
> +#define CR_CPT 1
> +#define CR_RST 2
> +
> +#define CR_COPY(op, a, b)				        \
> +	do {							\
> +		if (op == CR_CPT)				\
> +			a = b;					\
> +		else						\
> +			b = a;					\
> +	} while (0);

Drop the semicolon ^


> +
> +#define CR_COPY_ARRAY(op, a, b, count)				\
> +	do {							\
> +		BUILD_BUG_ON(sizeof(*a) != sizeof(*b));		\
> +		if (op == CR_CPT)				\
> +			memcpy(a, b, count * sizeof(*a));	\
> +		else						\
> +			memcpy(b, a, count * sizeof(*a));	\
> +	} while (0);
> +

You might want to employ __must_be_array() or similar to catch misuse.

Misuse might also be prevented by providing some documentation :)
_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/containers

[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux