kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: cocci@systeme.lip6.fr
Subject: Re: Determination for the number of named function parameters (with SmPL)
Date: Wed, 03 Dec 2014 10:30:43 +0000	[thread overview]
Message-ID: <547EE653.5000901@users.sourceforge.net> (raw)
In-Reply-To: <8DDAD79C-96D4-43BA-BC3F-F9EE237D2C60@gmail.com>

>> elfring@Sonne:~/Projekte/Coccinelle/Probe> cat list_parameter_numbers1.txt
>> number|counter
>> 0|29
> 
> I think the results are dubious. Only 29 functions with no parameters?
> That can't be right.

How do you think about to experiment a bit more with the following
semantic query approach?

@initialize:python@
@@
import sys
import sqlite3 as SQLite
connection = SQLite.connect(":memory:")
c = connection.cursor()
c.execute("""
create table numbers
(parameter_number integer,
 function text,
 source_file text,
 line integer,
 column integer,
 constraint c
 primary key (function, source_file, line, column)
)
without rowid""")

def store_number(count, fun, places):
    """Add an integer to an internal list."""
    for place in places:
        c.execute("""insert into numbers
(parameter_number,
 function,
 source_file,
 line,
 column
)
values (?, ?, ?, ?, ?)""",
                  (count,
                   fun,
                   place.file,
                   place.line,
                   int(place.column) + 1
                  )
                 )

@counting_parameters@
identifier work;
parameter list[number] pl;
position pos;
type return_type;
@@
 return_type work@pos(pl)
 {
  ...
 }

@script:python collection@
count << counting_parameters.number;
fun << counting_parameters.work;
places << counting_parameters.pos;
@@
store_number(count, fun, places)

@finalize:python@
@@
c.execute("""select count(*) nr from numbers""")
result = c.fetchone()

if result[0] > 0:
   c.execute("""create index x on numbers (parameter_number)""")
   c.execute("""select *
from numbers
where parameter_number > 12
order by parameter_number desc, function, source_file""")
   delimiter = "|"
   mark1 = ['"', '', '"']
   mark2 = ['"', '', '"']
   sys.stdout.write(delimiter.join(('"parameter number"',
                                    "function",
                                    '"source file"',
                                    "line",
                                    "column"
                                   )))
   sys.stdout.write("\r\n")
   for entry in c:
      mark1[1] = entry[1]
      mark2[1] = entry[2].replace('"', '""')
      sys.stdout.write(delimiter.join((str(entry[0]),
                                       ''.join(mark1),
                                       ''.join(mark2),
                                       str(entry[3]),
                                       str(entry[4])
                                      )))
      sys.stdout.write("\r\n")
else:
   sys.stderr.write("No result for this analysis!\n")

connection.close()


elfring@Sonne:~/Projekte/Linux/next-patched> XX=$(date) && spatch.opt -timeout 12 -sp-file ~/Projekte/Coccinelle/Probe/list_parameter_numbers1b.cocci -dir . > list_parameter_numbers1b.txt 2> list_parameter_numbers1b-errors.txt ; YY=$(date) && echo "$XX * $YY"
Mi 3. Dez 08:46:17 CET 2014 * Mi 3. Dez 09:13:14 CET 2014
elfring@Sonne:~/Projekte/Linux/next-patched> cat list_parameter_numbers1b.txt
"parameter number"|function|"source file"|line|column
22|"send_cap_msg"|"./fs/ceph/caps.c"|968|12
21|"dispc_ovl_setup_common"|"./drivers/video/fbdev/omap2/dss/dispc.c"|2414|12
...
13|"src_sync_cmd"|"./drivers/scsi/aacraid/src.c"|172|12
13|"submit_extent_page"|"./fs/btrfs/extent_io.c"|2761|12


Regards,
Markus

  parent reply	other threads:[~2014-12-03 10:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-01 11:12 Determination for the number of named function parameters (with SmPL) SF Markus Elfring
2014-12-01 11:23 ` walter harms
2014-12-02 16:30 ` Mark D Rustad
2014-12-02 16:48   ` Julia Lawall
2014-12-03 10:30   ` SF Markus Elfring [this message]
2014-12-16 19:30 ` 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=547EE653.5000901@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 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).