Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up

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

 



Am 06.03.21 um 12:26 schrieb René Scharfe.:
> Subject: [PATCH] fix xcalloc() argument order
>
> Pass the number of elements first and ther size second, as expected by
> xcalloc().  Provide a semantic patch, which was actually used to
> generate the rest of this patch.
>
> The semantic patch would generate flip-flop diffs if both arguments are
> equivalent sizeofs.
  ^^^^^^^^^^
Actually the sizeofs don't have to be equivalent for the flip-flop to
occur, so that word should be removed.

> We don't have such a case, and it's hard to imagine
> the usefulness of such an allocation.  If it ever occurs then we could
> deal with it by duplicating the rule in the semantic patch to make it
> cancel itself out, or we could change the code to use CALLOC_ARRAY.

> diff --git a/contrib/coccinelle/xcalloc.cocci b/contrib/coccinelle/xcalloc.cocci
> new file mode 100644
> index 0000000000..c291011607
> --- /dev/null
> +++ b/contrib/coccinelle/xcalloc.cocci
> @@ -0,0 +1,10 @@
> +@@
> +type T;
> +T *ptr;
> +expression n;
> +@@
> +  xcalloc(
> ++ n,
> +  \( sizeof(T) \| sizeof(*ptr) \)
> +- , n
> +  )




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux