* Determination for the number of named function parameters (with SmPL)
@ 2014-12-01 11:12 SF Markus Elfring
2014-12-01 11:23 ` walter harms
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: SF Markus Elfring @ 2014-12-01 11:12 UTC (permalink / raw)
To: cocci
Hello,
Would you like to know how many named function parameters are used in the source files?
How do you think about to try the following semantic query approach out a bit more?
@initialize:python@
@@
import sys
import sqlite3 as SQLite
connection = SQLite.connect(":memory:")
c = connection.cursor()
c.execute("""create table numbers (number integer)""")
delimiter = "|"
def store_number(count):
"""Add an integer to an internal list."""
c.execute("""insert into numbers (number) values (?)""",
(count, )
)
@counting_parameters@
identifier work;
parameter list[number] pl;
type return_type;
@@
return_type work(pl)
{
...
}
@script:python collection@
count << counting_parameters.number;
@@
store_number(count)
@finalize:python@
@@
c.execute("""select count(*) nr from numbers""")
result = c.fetchone()
if result[0] > 0:
c.execute("""create index x on numbers (number)""")
c.execute("select number, count(*) nr from numbers group by number")
sys.stdout.write(delimiter.join( ("number", "counter") ))
sys.stdout.write("\r\n")
for result in c:
sys.stdout.write(delimiter.join((str(result[0]),
str(result[1])
)))
sys.stdout.write("\r\n")
else:
sys.stderr.write("No result for this analysis!\n")
connection.close()
elfring@Sonne:~/Projekte/Coccinelle/Probe> XX=$(date) && spatch.opt -timeout 12 -sp-file list_parameter_numbers1.cocci -dir /usr/src/linux-stable > list_parameter_numbers1.txt 2> list_parameter_numbers1-errors.txt ; YY=$(date) && echo "$XX * $YY"
...
elfring@Sonne:~/Projekte/Coccinelle/Probe> cat list_parameter_numbers1.txt
number|counter
0|29
1|18261
2|15374
3|12237
4|8159
5|4339
6|2701
7|1183
8|518
9|260
10|146
11|83
12|42
13|21
14|9
15|7
16|2
17|4
18|1
21|1
22|1
Do you find such an analysis result from the source files for Linux 3.17.4
interesting for further considerations?
Regards,
Markus
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Determination for the number of named function parameters (with SmPL) 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-16 19:30 ` SF Markus Elfring 2 siblings, 0 replies; 6+ messages in thread From: walter harms @ 2014-12-01 11:23 UTC (permalink / raw) To: cocci Am 01.12.2014 12:12, schrieb SF Markus Elfring: > Hello, > > Would you like to know how many named function parameters are used in the source files? > > How do you think about to try the following semantic query approach out a bit more? > > @initialize:python@ > @@ > import sys > import sqlite3 as SQLite > connection = SQLite.connect(":memory:") > c = connection.cursor() > c.execute("""create table numbers (number integer)""") > delimiter = "|" > > def store_number(count): > """Add an integer to an internal list.""" > c.execute("""insert into numbers (number) values (?)""", > (count, ) > ) > > @counting_parameters@ > identifier work; > parameter list[number] pl; > type return_type; > @@ > return_type work(pl) > { > ... > } > > @script:python collection@ > count << counting_parameters.number; > @@ > store_number(count) > > @finalize:python@ > @@ > c.execute("""select count(*) nr from numbers""") > result = c.fetchone() > > if result[0] > 0: > c.execute("""create index x on numbers (number)""") > c.execute("select number, count(*) nr from numbers group by number") > sys.stdout.write(delimiter.join( ("number", "counter") )) > sys.stdout.write("\r\n") > for result in c: > sys.stdout.write(delimiter.join((str(result[0]), > str(result[1]) > ))) > sys.stdout.write("\r\n") > else: > sys.stderr.write("No result for this analysis!\n") > > connection.close() > > > > elfring@Sonne:~/Projekte/Coccinelle/Probe> XX=$(date) && spatch.opt -timeout 12 -sp-file list_parameter_numbers1.cocci -dir /usr/src/linux-stable > list_parameter_numbers1.txt 2> list_parameter_numbers1-errors.txt ; YY=$(date) && echo "$XX * $YY" > ... > elfring@Sonne:~/Projekte/Coccinelle/Probe> cat list_parameter_numbers1.txt > number|counter > 0|29 > 1|18261 > 2|15374 > 3|12237 > 4|8159 > 5|4339 > 6|2701 > 7|1183 > 8|518 > 9|260 > 10|146 > 11|83 > 12|42 > 13|21 > 14|9 > 15|7 > 16|2 > 17|4 > 18|1 > 21|1 > 22|1 > > > Do you find such an analysis result from the source files for Linux 3.17.4 > interesting for further considerations? > I am not sure that i understand these result. Does that mean there are actually functions taking 22 arguments ? re wh ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Determination for the number of named function parameters (with SmPL) 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 2014-12-16 19:30 ` SF Markus Elfring 2 siblings, 2 replies; 6+ messages in thread From: Mark D Rustad @ 2014-12-02 16:30 UTC (permalink / raw) To: cocci [-- Attachment #1: Type: text/plain, Size: 2713 bytes --] On Dec 1, 2014, at 3:12 AM, SF Markus Elfring <elfring@users.sourceforge.net> wrote: > Hello, > > Would you like to know how many named function parameters are used in the source files? > > How do you think about to try the following semantic query approach out a bit more? > > @initialize:python@ > @@ > import sys > import sqlite3 as SQLite > connection = SQLite.connect(":memory:") > c = connection.cursor() > c.execute("""create table numbers (number integer)""") > delimiter = "|" > > def store_number(count): > """Add an integer to an internal list.""" > c.execute("""insert into numbers (number) values (?)""", > (count, ) > ) > > @counting_parameters@ > identifier work; > parameter list[number] pl; > type return_type; > @@ > return_type work(pl) > { > ... > } > > @script:python collection@ > count << counting_parameters.number; > @@ > store_number(count) > > @finalize:python@ > @@ > c.execute("""select count(*) nr from numbers""") > result = c.fetchone() > > if result[0] > 0: > c.execute("""create index x on numbers (number)""") > c.execute("select number, count(*) nr from numbers group by number") > sys.stdout.write(delimiter.join( ("number", "counter") )) > sys.stdout.write("\r\n") > for result in c: > sys.stdout.write(delimiter.join((str(result[0]), > str(result[1]) > ))) > sys.stdout.write("\r\n") > else: > sys.stderr.write("No result for this analysis!\n") > > connection.close() > > > > elfring@Sonne:~/Projekte/Coccinelle/Probe> XX=$(date) && spatch.opt -timeout 12 -sp-file list_parameter_numbers1.cocci -dir /usr/src/linux-stable > list_parameter_numbers1.txt 2> list_parameter_numbers1-errors.txt ; YY=$(date) && echo "$XX * $YY" > ... > 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. > 1|18261 > 2|15374 > 3|12237 > 4|8159 > 5|4339 > 6|2701 > 7|1183 > 8|518 > 9|260 > 10|146 > 11|83 > 12|42 > 13|21 > 14|9 > 15|7 > 16|2 > 17|4 > 18|1 > 21|1 > 22|1 > > > Do you find such an analysis result from the source files for Linux 3.17.4 > interesting for further considerations? > > Regards, > Markus > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- Mark Rustad, MRustad@gmail.com [-- Attachment #2: Message signed with OpenPGP using GPGMail --] [-- Type: application/pgp-signature, Size: 841 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Determination for the number of named function parameters (with SmPL) 2014-12-02 16:30 ` Mark D Rustad @ 2014-12-02 16:48 ` Julia Lawall 2014-12-03 10:30 ` SF Markus Elfring 1 sibling, 0 replies; 6+ messages in thread From: Julia Lawall @ 2014-12-02 16:48 UTC (permalink / raw) To: cocci On Tue, 2 Dec 2014, Mark D Rustad wrote: > On Dec 1, 2014, at 3:12 AM, SF Markus Elfring <elfring@users.sourceforge.net> wrote: > > > Hello, > > > > Would you like to know how many named function parameters are used in the source files? > > > > How do you think about to try the following semantic query approach out a bit more? > > > > @initialize:python@ > > @@ > > import sys > > import sqlite3 as SQLite > > connection = SQLite.connect(":memory:") > > c = connection.cursor() > > c.execute("""create table numbers (number integer)""") > > delimiter = "|" > > > > def store_number(count): > > """Add an integer to an internal list.""" > > c.execute("""insert into numbers (number) values (?)""", > > (count, ) > > ) > > > > @counting_parameters@ > > identifier work; > > parameter list[number] pl; > > type return_type; > > @@ > > return_type work(pl) > > { > > ... > > } > > > > @script:python collection@ > > count << counting_parameters.number; > > @@ > > store_number(count) > > > > @finalize:python@ > > @@ > > c.execute("""select count(*) nr from numbers""") > > result = c.fetchone() > > > > if result[0] > 0: > > c.execute("""create index x on numbers (number)""") > > c.execute("select number, count(*) nr from numbers group by number") > > sys.stdout.write(delimiter.join( ("number", "counter") )) > > sys.stdout.write("\r\n") > > for result in c: > > sys.stdout.write(delimiter.join((str(result[0]), > > str(result[1]) > > ))) > > sys.stdout.write("\r\n") > > else: > > sys.stderr.write("No result for this analysis!\n") > > > > connection.close() > > > > > > > > elfring@Sonne:~/Projekte/Coccinelle/Probe> XX=$(date) && spatch.opt -timeout 12 -sp-file list_parameter_numbers1.cocci -dir /usr/src/linux-stable > list_parameter_numbers1.txt 2> list_parameter_numbers1-errors.txt ; YY=$(date) && echo "$XX * $YY" > > ... > > 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. Functions with no parameters should have a parameter list of the form (void). So 29 would be a high number... julia > > 1|18261 > > 2|15374 > > 3|12237 > > 4|8159 > > 5|4339 > > 6|2701 > > 7|1183 > > 8|518 > > 9|260 > > 10|146 > > 11|83 > > 12|42 > > 13|21 > > 14|9 > > 15|7 > > 16|2 > > 17|4 > > 18|1 > > 21|1 > > 22|1 > > > > > > Do you find such an analysis result from the source files for Linux 3.17.4 > > interesting for further considerations? > > > > Regards, > > Markus > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > Please read the FAQ at http://www.tux.org/lkml/ > > -- > Mark Rustad, MRustad@gmail.com > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Determination for the number of named function parameters (with SmPL) 2014-12-02 16:30 ` Mark D Rustad 2014-12-02 16:48 ` Julia Lawall @ 2014-12-03 10:30 ` SF Markus Elfring 1 sibling, 0 replies; 6+ messages in thread From: SF Markus Elfring @ 2014-12-03 10:30 UTC (permalink / raw) To: cocci >> 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Determination for the number of named function parameters (with SmPL) 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-16 19:30 ` SF Markus Elfring 2 siblings, 0 replies; 6+ messages in thread From: SF Markus Elfring @ 2014-12-16 19:30 UTC (permalink / raw) To: cocci Hello, Would you like to know how many named function parameters are used in the source files? How do you think about to try the following semantic query approach out a bit more? @initialize:python@ @@ import sys import sqlalchemy sys.stderr.write("\n".join( ("Using SQLAlchemy version:", sqlalchemy.__version__) )) sys.stderr.write("\n") from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String from sqlalchemy.orm import sessionmaker engine = create_engine("sqlite:///:memory:", echoúlse) base = declarative_base() class function(base): __tablename__ = "numbers" name = Column(String, primary_key=True) source_file = Column(String, primary_key=True) line = Column(Integer, primary_key=True) column = Column(Integer, primary_key=True) parameter_number = Column(Integer) def __repr__(self): return """<function(name='%s', source_file='%s', line='%s', column='%s', parameter_number='%s')>""" % (self.name, self.source_file, self.line, self.column, self.parameter_number) configured_session = sessionmaker(bind=engine) session = configured_session() base.metadata.create_all(engine) def store_number(fun, source, count): """Add an integer to an internal table.""" for place in source: entry = function(name = fun, source_file = place.file, line = place.line, column = int(place.column) + 1, parameter_number = count) session.add(entry) @counting_parameters@ identifier work; parameter list[number] pl; position pos; type return_type; @@ return_type work@pos(pl) { ... } @script:python collection@ fun << counting_parameters.work; count << counting_parameters.number; place << counting_parameters.pos; @@ store_number(fun, place, count) @finalize:python@ @@ session.commit() from sqlalchemy import func entries = session.query(func.count("*")).select_from(function).scalar() if entries > 0: delimiter = "|" sys.stdout.write(delimiter.join( ("number", "incidence") )) sys.stdout.write("\r\n") for number, incidence in session.query(function.parameter_number, func.count("*")).group_by(function.parameter_number): sys.stdout.write(delimiter.join( (str(number), str(incidence)) )) sys.stdout.write("\r\n") else: sys.stderr.write("No result for this analysis!\n") elfring@Sonne:~/Projekte/Coccinelle/Probe> XX=$(date) && spatch.opt -timeout 12 -sp-file list_parameter_numbers2.cocci -dir /usr/src/linux-stable > list_parameter_numbers2.txt 2> list_parameter_numbers2-errors.txt ; YY=$(date) && echo "$XX * $YY" Di 16. Dez 18:51:03 CET 2014 * Di 16. Dez 19:16:28 CET 2014 ... elfring@Sonne:~/Projekte/Coccinelle/Probe> cat list_parameter_numbers2.txt number|incidence 0|46 1|161270 2|103405 3|55551 4|25947 5|9569 6|4907 7|1860 8|738 9|335 10|177 11|108 12|64 13|20 14|11 15|8 16|4 17|5 18|1 21|1 22|1 Do you find such an analysis result from the source files for Linux 3.18 (with the help of the software "Coccinelle 1.0.0-rc23") interesting for further considerations? Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-12-16 19:30 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2014-12-16 19:30 ` SF 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).