> If you want something done, please do it yourself.
I hope that another clarification can be achieved also for the software
behaviour of the following source code analysis approach.
@initialize:python@
@@
import sqlalchemy, sys
sys.stderr.write("\n".join(["Using SQLAlchemy version:",
sqlalchemy.__version__]))
sys.stderr.write("\n")
from sqlalchemy import create_engine, Column, Integer, String
engine = create_engine("sqlite:///:memory:", echo = False)
from sqlalchemy.ext.declarative import declarative_base
base = declarative_base()
class pair(base):
__tablename__ = "pairs"
function = Column(String, primary_key = True)
source_file = Column(String, primary_key = True)
line = Column(Integer, primary_key = True)
column = Column(Integer, primary_key = True)
action = Column(String)
check = Column(String)
from sqlalchemy.orm import sessionmaker
configured_session = sessionmaker(bind = engine)
session = configured_session()
base.metadata.create_all(engine)
def store_positions(places, check_in, action_in):
"""Add source code positions to an internal table."""
for place in places:
entry = pair(function = place.current_element,
source_file = place.file,
line = place.line,
column = int(place.column) + 1,
action = action_in,
check = check_in
)
session.add(entry)
@find1@
expression action, e;
position p;
statement is, es;
@@
e = action(...);
if@p (<+... e ...+>)
is
else
es
@check1@
expression check;
position find1.p;
statement find1.is, find1.es;
@@
if@p (check)
is
else
es
@script:python collection1@
c << check1.check;
action << find1.action;
places << find1.p;
@@
store_positions(places, c, action)
@finalize:python@
@@
session.commit()
from sqlalchemy import func
entries = session.query(func.count("*")).select_from(pair).scalar()
if entries > 0:
delimiter = "|"
sys.stdout.write(delimiter.join(['action',
'check',
'"source file"',
"line",
"column"
]))
sys.stdout.write("\r\n")
for action, \
check, \
file, \
line, \
column in session.query(pair.action,
pair.check,
pair.source_file,
pair.line,
pair.column
).order_by(pair.action,
pair.check,
pair.source_file,
pair.line,
pair.column
):
sys.stdout.write(delimiter.join([action,
check,
file,
str(line),
str(column)
]))
sys.stdout.write("\r\n")
else:
sys.stderr.write("No result for this analysis!\n")
elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci
list_condition_checks_after_function_calls2.cocci
…
warning: iso drop_else does not match the code below on line 55
if@p (check) iselse es
…
elfring@Sonne:~/Projekte/Linux/next-patched> spatch
~/Projekte/Coccinelle/janitor/list_condition_checks_after_function_calls2.cocci
drivers/gpu/drm/mcde/mcde_drv.c
…
Using SQLAlchemy version:
1.3.10
HANDLING: drivers/gpu/drm/mcde/mcde_drv.c
No result for this analysis!
Will any software development possibilities become interesting here?
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci