All of lore.kernel.org
 help / color / mirror / Atom feed
From: elfring@users.sourceforge.net (SF Markus Elfring)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Finding labelled statements with SmPL
Date: Wed, 9 Dec 2015 10:20:27 +0100	[thread overview]
Message-ID: <5667F25B.1080901@users.sourceforge.net> (raw)

Hello,

I have tried another small SmPL script out.

@label_used@
identifier target, work;
type return_type;
@@
 return_type work(...)
 {
 ... when any
*target:
 ... when any
 }


Test example:
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/block/skd_main.c

elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt show_labels1.cocci ~/Projekte/Linux/next-patched/drivers/block/skd_main.c
?
@@ -778,7 +778,6 @@ static void skd_request_fn(struct reques
                        continue;
                }
 
-skip_sg:
                scsi_req->hdr.sg_list_len_bytes =
                        cpu_to_be32(skreq->sg_byte_count);
 
?
@@ -5114,10 +5094,8 @@ err_out_iounmap:
        if (skdev->pcie_error_reporting_is_enabled)
                pci_disable_pcie_error_reporting(pdev);
 
-err_out_regions:
        pci_release_regions(pdev);
 
-err_out:
        pci_disable_device(pdev);
        return rc;
 }


It seems that only jump labels are found by the shown source code analysis
approach so far.
http://en.cppreference.com/w/c/language/goto

Does an enumeration symbol like "SKD_IRQ_MSIX" fit to the properties of
a C identifier?


I imagine that case labels could also be matched by such a simple search pattern.
http://en.cppreference.com/w/c/language/switch
http://c0x.coding-guidelines.com/6.8.1.html

@label_used@
expression label;
identifier work;
type return_type;
@@
 return_type work(...)
 {
 ... when any
*label:
 ... when any
 }


elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt show_labels2.cocci ~/Projekte/Linux/next-patched/drivers/block/skd_main.c
init_defs_builtins: /usr/local/lib64/coccinelle/standard.h
115 116
Fatal error: exception Failure("minus: parse error: \n = File \"show_labels2.cocci\", line 9, column 6,  charpos = 115\n    around = ':', whole content = *label:\n")


Would you like to clarify these observations?

Regards,
Markus

             reply	other threads:[~2015-12-09  9:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09  9:20 SF Markus Elfring [this message]
2015-12-09 10:15 ` [Cocci] Finding labelled statements with SmPL Julia Lawall
2015-12-09 12:00   ` SF Markus Elfring
2015-12-09 12:54     ` Julia Lawall
2015-12-09 14:01       ` SF 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=5667F25B.1080901@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.