From: mcgrof@suse.com (Luis R. Rodriguez)
To: cocci@systeme.lip6.fr
Subject: [Cocci] minor issue: pretty printing for modified functions as arguments
Date: Thu, 2 Oct 2014 22:47:18 +0200 [thread overview]
Message-ID: <20141002204718.GS14081@wotan.suse.de> (raw)
In-Reply-To: <alpine.DEB.2.02.1410020835420.2068@localhost6.localdomain6>
On Thu, Oct 02, 2014 at 08:39:05AM +0200, Julia Lawall wrote:
> Is the problem that eg you get (indentation removed for readability):
>
> -int (*unknown)(char *param, char *val, const char *doing))
> +void *arg,int (*unknown)(char *param, char *val, const char *doing, void *arg))
>
> instead of
>
> -int (*unknown)(char *param, char *val, const char *doing))
> +void *arg,
> +int (*unknown)(char *param, char *val,
> + const char *doing, void *arg))
Yes, and if you look closely there is no reason to remove the unknown
line completely just to add it back, we really ideally only wish to
express on the final patch the addition of the void *arg as a third
argument to the callback, so this is what we should see on the patch
instead:
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -327,8 +327,9 @@ extern char *parse_args(const char *name,
unsigned num,
s16 level_min,
s16 level_max,
+ void *arg,
int (*unknown)(char *param, char *val,
- const char *doing));
+ const char *doing, void *arg));
So two things, one is the new void *arg passed to parse_args() and
the other is the addition of a third arguemtn to the callback.
In terms of style I think we can live with having the new arguments aligned
to where the first argument on the callback starts (tabs first and spaces
only if a tab does not fit).
This applies to the header file as well as on to the C file. Coccinelle
gives:
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -183,7 +183,7 @@ char *parse_args(const char *doing,
unsigned num,
s16 min_level,
s16 max_level,
- int (*unknown)(char *param, char *val, const char *doing))
+ void *arg,int (*unknown)(char *param, char *val, const char *doing, void *arg))
{
char *param, *val;
While we want:
diff --git a/kernel/params.c b/kernel/params.c
index 34f5270..4182607 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -90,8 +90,9 @@ static int parse_one(char *param,
unsigned num_params,
s16 min_level,
s16 max_level,
+ void *arg,
int (*handle_unknown)(char *param, char *val,
- const char *doing))
+ const char *doing, void *arg))
{
unsigned int i;
int err;
> I think that the problem is that Coccinelle does not try to respect 80
> columns when there are nested parentheses. But it seems like it could be
> possible to at least have the declaration of unknown moved to the next
> line.
Great!
Luis
next prev parent reply other threads:[~2014-10-02 20:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-01 18:40 [Cocci] minor issue: pretty printing for modified functions as arguments Luis R. Rodriguez
2014-10-01 19:49 ` SF Markus Elfring
2014-10-01 20:10 ` Luis R. Rodriguez
2014-10-01 22:03 ` Julia Lawall
2014-10-02 6:39 ` Julia Lawall
2014-10-02 20:47 ` Luis R. Rodriguez [this message]
2014-10-03 7:55 ` 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=20141002204718.GS14081@wotan.suse.de \
--to=mcgrof@suse.com \
--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.