{"thread":{"id":"52265","subject":"[PATCH] coccinelle: merge twelve rules from object_id.cocci","startedAt":"2019-11-14T12:10:45Z","lastAt":"2019-11-16T05:59:37Z","messageCount":2,"participants":["Markus Elfring","brian m. carlson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"386181","messageId":"6c9962c0-67c1-e700-c145-793ce6498099@web.de","threadId":"52265","inReplyTo":null,"subject":"[PATCH] coccinelle: merge twelve rules from object_id.cocci","fromName":"Markus Elfring","fromEmail":"markus.elfring@web.de","sentAt":"2019-11-14T12:10:26Z","receivedAt":"2019-11-14T12:10:45Z","isPatch":true,"sender":{"key":"markus.elfring@web.de","avatar":null},"body":"From: Markus Elfring <elfring@users.sourceforge.net>\nDate: Thu, 14 Nov 2019 12:48:27 +0100\n\nThis script contained transformation rules for the semantic patch language\nwhich used similar code.\nCombine these rules by using five SmPL disjunctions so that the run time\ncharacteristics can be nicer because of common usage of a few metavariables.\n\nSigned-off-by: Markus Elfring <elfring@users.sourceforge.net>\n---\n contrib/coccinelle/object_id.cocci | 89 +++++++++++++-----------------\n 1 file changed, 37 insertions(+), 52 deletions(-)\n\ndiff --git a/contrib/coccinelle/object_id.cocci b/contrib/coccinelle/object_id.cocci\nindex 3e536a9834..5e8fc4659a 100644\n--- a/contrib/coccinelle/object_id.cocci\n+++ b/contrib/coccinelle/object_id.cocci\n@@ -1,20 +1,33 @@\n @@\n-struct object_id OID;\n-@@\n-- is_null_sha1(OID.hash)\n-+ is_null_oid(&OID)\n-\n-@@\n+expression E;\n+struct object_id OID, OID2;\n struct object_id *OIDPTR;\n @@\n-- is_null_sha1(OIDPTR->hash)\n-+ is_null_oid(OIDPTR)\n-\n-@@\n-struct object_id OID;\n-@@\n+(\n+- is_null_sha1\n++ is_null_oid\n+             (\n+(\n+-             OID.hash\n++             &OID\n+|\n+              OIDPTR\n+-                   ->hash\n+)\n+             )\n+|\n - sha1_to_hex(OID.hash)\n + oid_to_hex(&OID)\n+|\n+- sha1_to_hex_r(E, OID.hash)\n++ oid_to_hex_r(E, &OID)\n+|\n+- hashclr(OID.hash)\n++ oidclr(&OID)\n+|\n+- hashcmp(OID.hash, OID2.hash)\n++ oidcmp(&OID, &OID2)\n+)\n\n @@\n identifier f != oid_to_hex;\n@@ -25,13 +38,6 @@ struct object_id *OIDPTR;\n + oid_to_hex(OIDPTR)\n   ...>}\n\n-@@\n-expression E;\n-struct object_id OID;\n-@@\n-- sha1_to_hex_r(E, OID.hash)\n-+ oid_to_hex_r(E, &OID)\n-\n @@\n identifier f != oid_to_hex_r;\n expression E;\n@@ -42,12 +48,6 @@ struct object_id *OIDPTR;\n + oid_to_hex_r(E, OIDPTR)\n   ...>}\n\n-@@\n-struct object_id OID;\n-@@\n-- hashclr(OID.hash)\n-+ oidclr(&OID)\n-\n @@\n identifier f != oidclr;\n struct object_id *OIDPTR;\n@@ -57,12 +57,6 @@ struct object_id *OIDPTR;\n + oidclr(OIDPTR)\n   ...>}\n\n-@@\n-struct object_id OID1, OID2;\n-@@\n-- hashcmp(OID1.hash, OID2.hash)\n-+ oidcmp(&OID1, &OID2)\n-\n @@\n identifier f != oidcmp;\n struct object_id *OIDPTR1, OIDPTR2;\n@@ -76,44 +70,35 @@ struct object_id *OIDPTR1, OIDPTR2;\n struct object_id *OIDPTR;\n struct object_id OID;\n @@\n+(\n - hashcmp(OIDPTR->hash, OID.hash)\n + oidcmp(OIDPTR, &OID)\n-\n-@@\n-struct object_id *OIDPTR;\n-struct object_id OID;\n-@@\n+|\n - hashcmp(OID.hash, OIDPTR->hash)\n + oidcmp(&OID, OIDPTR)\n+)\n\n @@\n-struct object_id *OIDPTR1;\n-struct object_id *OIDPTR2;\n+struct object_id * OIDPTR1, OIDPTR2;\n @@\n+(\n - oidcmp(OIDPTR1, OIDPTR2) == 0\n + oideq(OIDPTR1, OIDPTR2)\n-\n-@@\n-identifier f != hasheq;\n-expression E1, E2;\n-@@\n-  f(...) {<...\n-- hashcmp(E1, E2) == 0\n-+ hasheq(E1, E2)\n-  ...>}\n-\n-@@\n-struct object_id *OIDPTR1;\n-struct object_id *OIDPTR2;\n-@@\n+|\n - oidcmp(OIDPTR1, OIDPTR2) != 0\n + !oideq(OIDPTR1, OIDPTR2)\n+)\n\n @@\n identifier f != hasheq;\n expression E1, E2;\n @@\n   f(...) {<...\n+(\n+- hashcmp(E1, E2) == 0\n++ hasheq(E1, E2)\n+|\n - hashcmp(E1, E2) != 0\n + !hasheq(E1, E2)\n+)\n   ...>}\n--\n2.24.0\n\n"},{"id":"386363","messageId":"20191116055929.GB6538@camp.crustytoothpaste.net","threadId":"52265","inReplyTo":"6c9962c0-67c1-e700-c145-793ce6498099@web.de","subject":"Re: [PATCH] coccinelle: merge twelve rules from object_id.cocci","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-11-16T05:59:29Z","receivedAt":"2019-11-16T05:59:37Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-11-14 at 12:10:26, Markus Elfring wrote:\n> From: Markus Elfring <elfring@users.sourceforge.net>\n> Date: Thu, 14 Nov 2019 12:48:27 +0100\n> \n> This script contained transformation rules for the semantic patch language\n> which used similar code.\n> Combine these rules by using five SmPL disjunctions so that the run time\n> characteristics can be nicer because of common usage of a few metavariables.\n\nThis seems like a nice improvement.  It's probably quite obvious, but my\nskills with Coccinelle are rather limited, so I appreciate you cleaning\nthis up.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"}]}