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.elfr...@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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to