cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: wellington wallace <wellingtonwallace@gmail.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
Date: Mon, 3 Feb 2020 18:00:59 -0300	[thread overview]
Message-ID: <CAAJnyheEpd44ShTijdOAq6QZ9dyjJ387dcJDHg5qcd4aN90PYw@mail.gmail.com> (raw)
In-Reply-To: <72729ef6-f8df-942f-57aa-4b3fac75a20d@web.de>


[-- Attachment #1.1: Type: text/plain, Size: 1997 bytes --]

Hi!

I did not have the time to look at this file. Lots of places comparing two
chars indeed.

The strcmp output has to be compared to zero strcmp(src_name,
"equalizer_input_level") == 0. This is the result returned when the
arguments are equal.

Best Regards,
              Wellington.

On Mon, Feb 3, 2020 at 5:45 PM Markus Elfring <Markus.Elfring@web.de> wrote:

> Hello,
>
> I have tried the following small script variant out for
> the semantic patch language.
>
> @replacement@
> constant c;
> identifier text;
> expression x;
> statement is, es;
> @@
> char* text = x(...);
>
> if (
> +   strcmp(
>     text
> +   ,
> -   == std::string(
>     c
>     )
>    )
>    is
> else
>    es
>
>
> A corresponding transformation result from the software
> “Coccinelle 1.0.8-00029-ga549b9f0” looks promising (in principle).
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --c++
> replace_std_string_check_by_strcmp2.cocci
> PulseEffects-source_output_effects-excerpt2.cpp
> …
> @@ -1,7 +1,7 @@
>  void on_message_element(const GstBus* gst_bus, GstMessage* message,
> SourceOutputEffects* soe) {
>    char* src_name = GST_OBJECT_NAME(message->src);
>
> -  if (src_name == std::string("equalizer_input_level")) {
> +  if (strcmp(src_name, "equalizer_input_level")) {
>      soe->equalizer_input_level.emit(soe->get_peak(message));
>  // Deleted part
>    } else if (src_name == std::string("webrtc_output_level")) {
>
>
> 1. But I wonder about an additional space character at the beginning
>    of the shown function in the generated patch.
>
> 2. Will it become possible to achieve a similar change
>    if the specification “auto” would be used instead of
>    the data type “char*”?
>
> https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6
>
> Regards,
> Markus
>


-- 
Prof.° Wellington Wallace Miguel Melo

CEFET/RJ Uned Nova Iguaçu

[-- Attachment #1.2: Type: text/html, Size: 2826 bytes --]

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  parent reply	other threads:[~2020-02-03 21:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-03 20:45 [Cocci] Replacing a std::string check by strcmp() with SmPL Markus Elfring
2020-02-03 20:52 ` Julia Lawall
2020-02-03 21:13   ` Markus Elfring
2020-02-03 21:28     ` Julia Lawall
2020-02-04  8:11       ` Markus Elfring
2020-02-04  8:14         ` Julia Lawall
2020-02-04  8:39           ` Markus Elfring
2020-02-04 10:38           ` [Cocci] Replacing usages of “auto” with SmPL? Markus Elfring
2020-02-04 11:01             ` Julia Lawall
2020-02-04 11:45               ` Markus Elfring
2020-02-04 12:07                 ` Julia Lawall
2020-02-04 12:18                   ` Markus Elfring
2020-02-03 21:31     ` [Cocci] Replacing a std::string check by strcmp() with SmPL Julia Lawall
2020-02-04  8:19       ` Markus Elfring
2020-02-04 12:24   ` [Cocci] Searching for usage of “auto” with SmPL? Markus Elfring
2020-02-04 12:42     ` Julia Lawall
2020-02-04 12:52       ` Markus Elfring
2020-02-03 21:00 ` wellington wallace [this message]
2020-02-04 13:02   ` [Cocci] Replacing a std::string check by strcmp() with SmPL Markus Elfring
2020-02-04 13:19     ` Julia Lawall
2020-02-04 13:28       ` Markus Elfring
2020-02-04 13:47         ` Julia Lawall
2020-02-04 14:08           ` Markus Elfring
     [not found]             ` <alpine.DEB.2.21.2002041524400.3345@hadrien>
2020-02-04 14:42               ` [Cocci] Usage concerns around the SmPL construct “<+... … ...+>” 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=CAAJnyheEpd44ShTijdOAq6QZ9dyjJ387dcJDHg5qcd4aN90PYw@mail.gmail.com \
    --to=wellingtonwallace@gmail.com \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@systeme.lip6.fr \
    /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 NNTP newsgroup(s).