Hello,

I have tried further script variants out for the semantic patch language
(according to the software combination “Coccinelle 1.0.8-00087-g7cf2c23e”).

Source code example:
// SPDX-License-Identifier: GPL-2.0-only
// deleted part
static int sca3000_read_data(struct sca3000_state *st,
                             u8 reg_address_high,
                             u8 *rx,
                             int len)
{
        int ret;
        struct spi_transfer xfer[2] = {
                {
                        .len = 1,
                        .tx_buf = st->tx,
                }, {
                        .len = len,
                        .rx_buf = rx,
                }
        };
// deleted part
        ret = spi_sync_transfer(st->us, xfer, ARRAY_SIZE(xfer));
        if (ret) {
                dev_err(get_device(&st->us->dev), "problem reading register");
                return ret;
        }

        return 0;
}
// deleted part


See also:
https://lore.kernel.org/patchwork/patch/1236743/
https://lore.kernel.org/linux-iio/[email protected]/


The following search approach points a questionable source code place out
as expected.

@display@
@@
(dev_err
|dev_info
)       (
*        get_device(...),
         ...
        )


elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch 
show_get_device_as_message_parameter2.cocci ../Probe/sca3000-excerpt-20200505.c
…
@@ -18,7 +18,6 @@ static int sca3000_read_data(struct sca3
 // deleted part
        ret = spi_sync_transfer(st->us, xfer, ARRAY_SIZE(xfer));
        if (ret) {
-               dev_err(get_device(&st->us->dev), "problem reading register");
                return ret;
        }


But I do not get the same output for the following SmPL script.

@display@
@@
(dev_err
|dev_info
)       (
*        <+... get_device(...) ...+>
        )


Is such a test result worth for further software development considerations?
Does the application of the SmPL nest construct need any more clarification?
https://github.com/coccinelle/coccinelle/issues/114

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to