{"thread":{"id":"52249","subject":"[PATCH] coccinelle: combine two rules from qsort.cocci","startedAt":"2019-11-12T19:23:57Z","lastAt":"2019-11-12T19:23:57Z","messageCount":1,"participants":["Markus Elfring"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"386038","messageId":"c19a6e52-3c13-1ff1-a313-d0d951328e29@web.de","threadId":"52249","inReplyTo":null,"subject":"[PATCH] coccinelle: combine two rules from qsort.cocci","fromName":"Markus Elfring","fromEmail":"markus.elfring@web.de","sentAt":"2019-11-12T19:23:53Z","receivedAt":"2019-11-12T19:23:57Z","isPatch":true,"sender":{"key":"markus.elfring@web.de","avatar":null},"body":"From: Markus Elfring <elfring@users.sourceforge.net>\nDate: Tue, 12 Nov 2019 20:20:13 +0100\n\nThis script contained two transformation rules for the semantic patch language\nwhich used duplicate code.\n\n* Reduce duplication by merging common code from these rules.\n\n* Use a SmPL disjunction for the pointer determination according to\n  a sizeof operator.\n\nSigned-off-by: Markus Elfring <elfring@users.sourceforge.net>\n---\n contrib/coccinelle/qsort.cocci | 13 +++++--------\n 1 file changed, 5 insertions(+), 8 deletions(-)\n\ndiff --git a/contrib/coccinelle/qsort.cocci b/contrib/coccinelle/qsort.cocci\nindex 22b93a9966..1c9a12c7c0 100644\n--- a/contrib/coccinelle/qsort.cocci\n+++ b/contrib/coccinelle/qsort.cocci\n@@ -1,14 +1,11 @@\n @@\n expression base, nmemb, compar;\n @@\n-- qsort(base, nmemb, sizeof(*base), compar);\n-+ QSORT(base, nmemb, compar);\n-\n-@@\n-expression base, nmemb, compar;\n-@@\n-- qsort(base, nmemb, sizeof(base[0]), compar);\n-+ QSORT(base, nmemb, compar);\n+-qsort\n++QSORT\n+      (base, nmemb,\n+-      sizeof( \\( *base \\| base[0] \\) ),\n+       compar);\n\n @@\n type T;\n--\n2.24.0\n\n"}]}