Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: cocci@inria.fr
Cc: Thomas Adam <thomas@fvwm.org>
Subject: [cocci] Checking a transformation approach for the avoidance of duplicate code
Date: Sat, 2 Sep 2023 19:55:20 +0200	[thread overview]
Message-ID: <7e3fdd0f-e691-4ebd-9de9-4fbdb6ece973@web.de> (raw)

Hello,

The analysis tool “Cppcheck 2.10.3-3.2” pointed a source code place out
for further development considerations.

https://github.com/fvwmorg/fvwm3/blob/c9d00184ac3ab534e0f0ba5683106879a35857f6/fvwm/colorset.c#L965

(style) Condition 'tint==NULL' is always true [knownConditionTrueFalse]

See also a change suggestion:
Simplify data processing for tint colour in parse_colorset()
https://github.com/fvwmorg/fvwm3/issues/897


I constructed another SmPL script variant for a desirable transformation.


@replacement@
statement s1, s2, s3;
@@
-if (tint != NULL)
-{
- s1
- s2
- cs->tint = GetColor(tint);
- s3
-}
-else if (tint == NULL)
-{
- s1
- s2
- cs->tint = GetColor(black);
- s3
-}
+s1
+s2
+cs->tint = GetColor(tint ? tint : black);
+s3


Now I wonder why a corresponding patch is not generated by the software
“Coccinelle 1.1.1-00478-g0afff7fa” (OCaml 5.0) at the moment.
I would appreciate further advices.

Regards,
Markus

             reply	other threads:[~2023-09-02 17:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-02 17:55 Markus Elfring [this message]
2023-09-02 18:08 ` [cocci] Checking a transformation approach for the avoidance of duplicate code Julia Lawall
2023-09-02 18:25   ` Markus Elfring
2023-09-02 18:33     ` Julia Lawall
2023-09-02 18:42       ` Markus Elfring
2023-09-02 19:01         ` Julia Lawall
2023-09-03  6:40           ` Markus Elfring
2023-09-03  7:56           ` Markus Elfring
2023-09-03  8:34             ` [cocci] Checking an analysis " Markus Elfring
2023-09-06  7:10               ` Markus Elfring
2023-09-06  7:14                 ` Julia Lawall
2023-09-06  7:20                   ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e3fdd0f-e691-4ebd-9de9-4fbdb6ece973@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=thomas@fvwm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).