cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Checking an application of the SmPL construct “<+... … ...+>”
@ 2020-05-07 16:00 Markus Elfring
  2020-05-07 16:19 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2020-05-07 16:00 UTC (permalink / raw)
  To: Coccinelle; +Cc: Christophe Jaillet

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/20200506035206.192173-1-christophe.jaillet@wanadoo.fr/


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-07 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 16:00 [Cocci] Checking an application of the SmPL construct “<+... … ...+>” Markus Elfring
2020-05-07 16:19 ` Julia Lawall
2020-05-07 16:33   ` Markus Elfring

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).