{"thread":{"id":"44302","subject":"Re: [PATCH] cocci: avoid self-references in object_id transformations","startedAt":"2016-10-16T00:33:47Z","lastAt":"2016-10-17T21:11:54Z","messageCount":5,"participants":["brian m. carlson","René Scharfe","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"304193","messageId":"20161015134503.u3aznujploqee2le@vauxhall.crustytoothpaste.net","threadId":"44302","inReplyTo":"a5ed26c0-7fea-259c-74c1-0cd870a35290@web.de","subject":"Re: [PATCH] cocci: avoid self-references in object_id transformations","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2016-10-15T13:45:03Z","receivedAt":"2016-10-16T00:33:47Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Sat, Oct 15, 2016 at 10:25:34AM +0200, René Scharfe wrote:\n> The object_id functions oid_to_hex, oid_to_hex_r, oidclr, oidcmp, and\n> oidcpy are defined as wrappers of their legacy counterparts sha1_to_hex,\n> sha1_to_hex_r, hashclr, hashcmp, and hashcpy, respectively.  Make sure\n> that the Coccinelle transformations for converting legacy function calls\n> are not applied to these wrappers themselves, which would result in\n> tautological declarations.\n\nAh, yes, this is a good idea.  I've had to hack around this, but this is\nmuch better than having to fix it up by hand.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\n+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"304212","messageId":"a5ed26c0-7fea-259c-74c1-0cd870a35290@web.de","threadId":"44302","inReplyTo":null,"subject":"[PATCH] cocci: avoid self-references in object_id transformations","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2016-10-15T08:25:34Z","receivedAt":"2016-10-16T00:34:21Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"The object_id functions oid_to_hex, oid_to_hex_r, oidclr, oidcmp, and\noidcpy are defined as wrappers of their legacy counterparts sha1_to_hex,\nsha1_to_hex_r, hashclr, hashcmp, and hashcpy, respectively.  Make sure\nthat the Coccinelle transformations for converting legacy function calls\nare not applied to these wrappers themselves, which would result in\ntautological declarations.\n\nWe can remove the added guards once the object_id functions stand on\ntheir own.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n contrib/coccinelle/object_id.cocci | 15 +++++++++++++++\n 1 file changed, 15 insertions(+)\n\ndiff --git a/contrib/coccinelle/object_id.cocci b/contrib/coccinelle/object_id.cocci\nindex 0307624..09afdbf 100644\n--- a/contrib/coccinelle/object_id.cocci\n+++ b/contrib/coccinelle/object_id.cocci\n@@ -17,10 +17,13 @@ expression E1;\n + oid_to_hex(&E1)\n \n @@\n+identifier f != oid_to_hex;\n expression E1;\n @@\n+  f(...) {...\n - sha1_to_hex(E1->hash)\n + oid_to_hex(E1)\n+  ...}\n \n @@\n expression E1, E2;\n@@ -29,10 +32,13 @@ expression E1, E2;\n + oid_to_hex_r(E1, &E2)\n \n @@\n+identifier f != oid_to_hex_r;\n expression E1, E2;\n @@\n+   f(...) {...\n - sha1_to_hex_r(E1, E2->hash)\n + oid_to_hex_r(E1, E2)\n+  ...}\n \n @@\n expression E1;\n@@ -41,10 +47,13 @@ expression E1;\n + oidclr(&E1)\n \n @@\n+identifier f != oidclr;\n expression E1;\n @@\n+  f(...) {...\n - hashclr(E1->hash)\n + oidclr(E1)\n+  ...}\n \n @@\n expression E1, E2;\n@@ -53,10 +62,13 @@ expression E1, E2;\n + oidcmp(&E1, &E2)\n \n @@\n+identifier f != oidcmp;\n expression E1, E2;\n @@\n+  f(...) {...\n - hashcmp(E1->hash, E2->hash)\n + oidcmp(E1, E2)\n+  ...}\n \n @@\n expression E1, E2;\n@@ -77,10 +89,13 @@ expression E1, E2;\n + oidcpy(&E1, &E2)\n \n @@\n+identifier f != oidcpy;\n expression E1, E2;\n @@\n+  f(...) {...\n - hashcpy(E1->hash, E2->hash)\n + oidcpy(E1, E2)\n+  ...}\n \n @@\n expression E1, E2;\n-- \n2.10.1\n\n"},{"id":"304294","messageId":"xmqqlgxmvof2.fsf@gitster.mtv.corp.google.com","threadId":"44302","inReplyTo":"20161015134503.u3aznujploqee2le@vauxhall.crustytoothpaste.net","subject":"Re: [PATCH] cocci: avoid self-references in object_id transformations","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-10-17T18:08:33Z","receivedAt":"2016-10-17T18:08:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> On Sat, Oct 15, 2016 at 10:25:34AM +0200, René Scharfe wrote:\n>> The object_id functions oid_to_hex, oid_to_hex_r, oidclr, oidcmp, and\n>> oidcpy are defined as wrappers of their legacy counterparts sha1_to_hex,\n>> sha1_to_hex_r, hashclr, hashcmp, and hashcpy, respectively.  Make sure\n>> that the Coccinelle transformations for converting legacy function calls\n>> are not applied to these wrappers themselves, which would result in\n>> tautological declarations.\n>\n> Ah, yes, this is a good idea.  I've had to hack around this, but this is\n> much better than having to fix it up by hand.\n\nYes, seeing an empty *.cocci.patch files after running coccicheck is\na great feeling, but without something like this patch, we can never\nreach that goal ;-)\n\nThanks.\n\n... oops.  Totally unrelated to this patch, but I see these in\nstrbuf.cocci.patch (this is at the tip of 'pu'), which are total\nnonsense.  Perhaps I am running a way-stale spatch?  It claims to be\n\"spatch version 1.0.0-rc19 with Python support and with PCRE support\"\n\n--- date.c\n+++ /tmp/cocci-output-21568-bd3448-date.c\n@@ -179,7 +179,7 @@ const char *show_date(unsigned long time\n \n \tif (mode->type == DATE_UNIX) {\n \t\tstrbuf_reset(&timebuf);\n-\t\tstrbuf_addf(&timebuf, \"%lu\", time);\n+\t\tstrbuf_addstr(&timebuf, time);\n \t\treturn timebuf.buf;\n \t}\n \n--- log-tree.c\n+++ /tmp/cocci-output-21608-b02087-log-tree.c\n@@ -400,7 +400,7 @@ void log_write_email_headers(struct rev_\n \t\textra_headers = subject_buffer;\n \n \t\tif (opt->numbered_files)\n-\t\t\tstrbuf_addf(&filename, \"%d\", opt->nr);\n+\t\t\tstrbuf_addstr(&filename, opt->nr);\n \t\telse\n \t\t\tfmt_output_commit(&filename, commit, opt);\n \t\tsnprintf(buffer, sizeof(buffer) - 1,\n\n"},{"id":"304303","messageId":"014ef44e-9dd8-40b3-a3ec-b483f938ee02@web.de","threadId":"44302","inReplyTo":"xmqqlgxmvof2.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] cocci: avoid self-references in object_id transformations","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2016-10-17T20:04:43Z","receivedAt":"2016-10-17T20:05:24Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 17.10.2016 um 20:08 schrieb Junio C Hamano:\n> ... oops.  Totally unrelated to this patch, but I see these in\n> strbuf.cocci.patch (this is at the tip of 'pu'), which are total\n> nonsense.  Perhaps I am running a way-stale spatch?  It claims to be\n> \"spatch version 1.0.0-rc19 with Python support and with PCRE support\"\n> \n> --- date.c\n> +++ /tmp/cocci-output-21568-bd3448-date.c\n> @@ -179,7 +179,7 @@ const char *show_date(unsigned long time\n>  \n>  \tif (mode->type == DATE_UNIX) {\n>  \t\tstrbuf_reset(&timebuf);\n> -\t\tstrbuf_addf(&timebuf, \"%lu\", time);\n> +\t\tstrbuf_addstr(&timebuf, time);\n>  \t\treturn timebuf.buf;\n>  \t}\n>  \n> --- log-tree.c\n> +++ /tmp/cocci-output-21608-b02087-log-tree.c\n> @@ -400,7 +400,7 @@ void log_write_email_headers(struct rev_\n>  \t\textra_headers = subject_buffer;\n>  \n>  \t\tif (opt->numbered_files)\n> -\t\t\tstrbuf_addf(&filename, \"%d\", opt->nr);\n> +\t\t\tstrbuf_addstr(&filename, opt->nr);\n>  \t\telse\n>  \t\t\tfmt_output_commit(&filename, commit, opt);\n>  \t\tsnprintf(buffer, sizeof(buffer) - 1,\n\nI get these instead with 6513eabcbcbcfa684d4bb2d57f61c662b870b5ca on\nDebian testing with its \"spatch version 1.0.4 with Python support and\nwith PCRE support\", which look legit:\n\n--- sequencer.c\n+++ /tmp/cocci-output-40365-db7a71-sequencer.c\n@@ -159,7 +159,7 @@ int sequencer_remove_state(struct replay\n \t\tfree(opts->xopts[i]);\n \tfree(opts->xopts);\n \n-\tstrbuf_addf(&dir, \"%s\", get_dir(opts));\n+\tstrbuf_addstr(&dir, get_dir(opts));\n \tremove_dir_recursively(&dir, 0);\n \tstrbuf_release(&dir);\n \n--- builtin/branch.c\n+++ /tmp/cocci-output-40858-a86d1a-branch.c\n@@ -316,7 +316,7 @@ static char *build_format(struct ref_fil\n \n \tif (filter->verbose) {\n \t\tstrbuf_addf(&local, \"%%(align:%d,left)%%(refname:strip=2)%%(end)\", maxwidth);\n-\t\tstrbuf_addf(&local, \"%s\", branch_get_color(BRANCH_COLOR_RESET));\n+\t\tstrbuf_addstr(&local, branch_get_color(BRANCH_COLOR_RESET));\n \t\tstrbuf_addf(&local, \" %%(objectname:short=7) \");\n \n \t\tif (filter->verbose > 1)\n"},{"id":"304309","messageId":"xmqqeg3eu1da.fsf@gitster.mtv.corp.google.com","threadId":"44302","inReplyTo":"014ef44e-9dd8-40b3-a3ec-b483f938ee02@web.de","subject":"Re: [PATCH] cocci: avoid self-references in object_id transformations","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-10-17T21:11:45Z","receivedAt":"2016-10-17T21:11:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> I get these instead with 6513eabcbcbcfa684d4bb2d57f61c662b870b5ca on\n> Debian testing with its \"spatch version 1.0.4 with Python support and\n> with PCRE support\", which look legit:\n\nThey do look good.  So I'd stop worrying about it and see how\npainful to update my copy of spatch would be.\n\nThanks.\n"}]}