Re: [PATCH v3* 11/33] commit.c: add repo_get_commit_tree()

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

 



On Sat, Apr 13, 2019 at 05:16:00PM +0700, Nguyễn Thái Ngọc Duy wrote:
>  OK how about this? set_commit_tree() is added to keeps that long line
>  in commit.cocci down. I also make commit.cocci generate invalid
>  repo_get_commit_tree() code this time.

> diff --git a/contrib/coccinelle/commit.cocci b/contrib/coccinelle/commit.cocci
> index c49aa558f0..ee1dc29234 100644
> --- a/contrib/coccinelle/commit.cocci
> +++ b/contrib/coccinelle/commit.cocci
> @@ -11,18 +11,14 @@ expression c;
>  + get_commit_tree_oid(c)->hash
>  
>  // These excluded functions must access c->maybe_tree direcly.
> +// Note that if c->maybe_tree is written somewhere outside of these
> +// functions, then the recommended transformation will be bogus with
> +// repo_get_commit_tree() on the LHS.

We could prevent transformations putting repo_get_commit_tree() on the
LHS by inserting the semantic patch:

  @@
  identifier f !~ "^set_commit_tree$";
  expression c;
  expression s;
  @@
    f(...) {<...
  - c->maybe_tree = s
  + set_commit_tree(c, s)
    ...>}

before this one.


>  @@
> -identifier f !~ "^(get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit)$";
> +identifier f !~ "^(repo_get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit|set_commit_tree)$";
>  expression c;
>  @@
>    f(...) {<...
>  - c->maybe_tree
> -+ get_commit_tree(c)
> ++ repo_get_commit_tree(specify_the_right_repo_here, c)
>    ...>}
> -
> -@@
> -expression c;
> -expression s;
> -@@
> -- get_commit_tree(c) = s
> -+ c->maybe_tree = s



[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