From: elfring@users.sourceforge.net (SF Markus Elfring)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Finding function implementations that call only a single function.
Date: Sun, 07 Dec 2014 10:15:30 +0100 [thread overview]
Message-ID: <54841AB2.6070609@users.sourceforge.net> (raw)
In-Reply-To: <alpine.DEB.2.02.1412070749130.2044@localhost6.localdomain6>
>> I hope that a log format selection does not block a constructive dialogue
>> for the clarification of interesting SmPL rules.
>
> Sorry but it does.
If you insist on a log file format in this way, you can also get it.
How should your preferred log format look exactly?
> I won't look at it further until there is only one SmPL file, it contains
> a small numnber of rules,
I am going try again to inform you about software development progress in smaller steps.
> there is a small C file,
I attached one that contains the function implementations that should be found
with another semantic patch approach.
> and there is a high level description of what you expect.
I expect the following list of properties for four functions after the selection
of a single source file for a data extraction.
They fit to the filter criterium that only a single function is called within
their implementations.
>>>> static|function|"data type"|"parameter"|"source file"|line|column
>>>> 1|ast_ttm_mem_global_init|"struct drm_global_reference"|ref|"/usr/src/linux-stable/drivers/gpu/drm/ast/ast_ttm.c"|39|1
>>>> 1|ast_ttm_mem_global_release|"struct drm_global_reference"|ref|"/usr/src/linux-stable/drivers/gpu/drm/ast/ast_ttm.c"|45|1
>>>> 1|ast_ttm_tt_populate|"struct ttm_tt *"|ttm|"/usr/src/linux-stable/drivers/gpu/drm/ast/ast_ttm.c"|228|12
>>>> 1|ast_ttm_tt_unpopulate|"struct ttm_tt *"|ttm|"/usr/src/linux-stable/drivers/gpu/drm/ast/ast_ttm.c"|233|13
>
> How much of this output is actually relevant to your problem?
This the expected result in principle.
> For example, you ask me to work on a specific file.
Yes. - I find it appropriate for further tests.
> So why does the output have to contain the file name.
The file name should be copied from the source code position metavariables
to the desired list display.
> Why does the output need to contain the parameter name, etc.
The involved data type should be directly seen from the function signature.
> All that it needs is the function name and the line number,
The text column is also needed to make a found source code position unique.
> because there might be more than one function with the same name.
Yes. - Functions are also occasionally redefined because of conditional compilation.
> The rest is noise and unreadable
> - there are no space, there are lots of quotes, there sre more than 80 columns, etc.
Would you like to introduce another coding style convention?
> I can only help you with something that is matched but should not be,
> or something that is not matched but should be.
I hope that we can keep our dialogue constructive on such issue improvements.
It seems that we can eventually clarify a part of my observations (without additional
logging) already from a SmPL pattern like the following.
@single_function_call@
identifier caller, input, work;
type input_type, return_type;
@@
*return_type caller(input_type input)
{
(
work(input);
|
return work(input);
)
}
@single_function_call_with_pointer@
identifier caller, element, input, work;
type input_type, return_type;
@@
*return_type caller(input_type * input)
{
(
work(input->element);
|
return work(input->element);
)
}
elfring at Sonne:~/Projekte/Coccinelle/Probe> spatch.opt -sp-file find_single_function_call1.cocci ast_ttm-excerpt1.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: ast_ttm-excerpt1.c
diff =
--- ast_ttm-excerpt1.c
+++ /tmp/cocci-output-19572-537bbf-ast_ttm-excerpt1.c
@@ -25,24 +25,18 @@
/*
* Authors: Dave Airlie <airlied@redhat.com>
*/
-static int
-ast_ttm_mem_global_init(struct drm_global_reference *ref)
{
return ttm_mem_global_init(ref->object);
}
-static void
-ast_ttm_mem_global_release(struct drm_global_reference *ref)
{
ttm_mem_global_release(ref->object);
}
-static int ast_ttm_tt_populate(struct ttm_tt *ttm)
{
return ttm_pool_populate(ttm);
}
-static void ast_ttm_tt_unpopulate(struct ttm_tt *ttm)
{
ttm_pool_unpopulate(ttm);
}
One of my concerns here is the influence of the function return type
on the SmPL evaluation speed so that more fine-tuning will be appropriate
for the filter patterns.
Regards,
Markus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ast_ttm-excerpt1.c
Type: text/x-csrc
Size: 1631 bytes
Desc: not available
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20141207/6a30a4e1/attachment.bin>
next prev parent reply other threads:[~2014-12-07 9:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-28 22:33 [Cocci] Finding function implementations that call only a single function SF Markus Elfring
[not found] ` <alpine.DEB.2.02.1412032218310.2303@localhost6.localdomain6>
[not found] ` <547F8C2B.5090601@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1412032334330.2303@localhost6.localdomain6>
2014-12-05 14:20 ` SF Markus Elfring
[not found] ` <alpine.DEB.2.10.1412051633240.2360@hadrien>
2014-12-05 20:05 ` SF Markus Elfring
[not found] ` <54834F76.1090104@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1412061955440.2042@hadrien>
[not found] ` <548358DE.6020409@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1412062139570.2256@localhost6.localdomain6>
[not found] ` <548371FB.9060402@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1412062219530.2256@localhost6.localdomain6>
[not found] ` <54837413.8000902@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1412062232470.2256@localhost6.localdomain6>
[not found] ` <5483806D.3070805@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1412062342540.2256@localhost6.localdomain6>
[not found] ` <5483902E.8060109@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1412070749130.2044@localhost6.localdomain6>
2014-12-07 9:15 ` SF Markus Elfring [this message]
2014-12-07 9:31 ` Julia Lawall
2014-12-07 10:22 ` SF Markus Elfring
2014-12-07 10:28 ` Julia Lawall
2014-12-07 10:37 ` SF Markus Elfring
2014-12-07 11:45 ` Julia Lawall
2014-12-07 12:00 ` SF Markus Elfring
2014-12-07 12:38 ` Julia Lawall
2014-12-07 14:41 ` SF Markus Elfring
2014-12-17 15:30 ` SF Markus Elfring
2014-12-17 19:20 ` Julia Lawall
2014-12-17 20:30 ` [Cocci] Distinguishing pointer data types with SmPL 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=54841AB2.6070609@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.