* [PATCH 00/12] drop unneeded newline
@ 2017-12-27 14:51 Julia Lawall
2017-12-27 14:51 ` [PATCH 03/12] net: dccp: " Julia Lawall
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Julia Lawall @ 2017-12-27 14:51 UTC (permalink / raw)
To: dri-devel
Cc: dev, linux-s390, linux-scsi, dccp, Alexander Shishkin, netdev,
kernel-janitors, linux-kernel, amd-gfx, cluster-devel,
esc.storagedev, Namhyung Kim, linux-ext4, Jiri Olsa,
linux-arm-kernel, linux-media
Drop newline at the end of a message string when the printing function adds
a newline.
The complete semantic patch that detects this issue is as shown below
(http://coccinelle.lip6.fr/). It works in two phases - the first phase
counts how many uses of a function involve a newline and how many don't,
and then the second phase removes newlines in the case of calls where a
newline is used one fourth of the times or less.
This approach is only moderately reliable, and all patches have been
checked to ensure that the newline is not needed.
This also converts some cases of string concatenation to single strings in
modified code, as this improves greppability.
// <smpl>
virtual after_start
@initialize:ocaml@
@@
let withnl = Hashtbl.create 101
let withoutnl = Hashtbl.create 101
let ignore =
["strcpy";"strlcpy";"strcat";"strlcat";"strcmp";"strncmp";"strcspn";
"strsep";"sprintf";"printf";"strncasecmp";"seq_printf";"strstr";"strspn";
"strlen";"strpbrk";"strtok_r";"memcmp";"memcpy"]
let dignore = ["tools";"samples"]
let inc tbl k =
let cell =
try Hashtbl.find tbl k
with Not_found ->
let cell = ref 0 in
Hashtbl.add tbl k cell;
cell in
cell := 1 + !cell
let endnl c =
let len = String.length c in
try
String.get c (len-3) = '\\' && String.get c (len-2) = 'n' &&
String.get c (len-1) = '"'
with _ -> false
let clean_string s extra =
let pieces = Str.split (Str.regexp "\" \"") s in
let nonempty s =
not (s = "") && String.get s 0 = '"' && not (String.get s 1 = '"') in
let rec loop = function
[] -> []
| [x] -> [x]
| x::y::rest ->
if nonempty x && nonempty y
then
let xend = String.get x (String.length x - 2) = ' ' in
let yend = String.get y 1 = ' ' in
match (xend,yend) with
(true,false) | (false,true) -> x :: (loop (y::rest))
| (true,true) ->
x :: (loop (((String.sub y 0 (String.length y - 2))^"\"")::rest))
| (false,false) ->
((String.sub x 0 (String.length x - 1)) ^ " \"") ::
(loop (y::rest))
else x :: (loop (y::rest)) in
(String.concat "" (loop pieces))^extra
@r depends on !after_start@
constant char[] c;
expression list[n] es;
identifier f;
position p;
@@
f@p(es,c,...)
@script:ocaml@
f << r.f;
n << r.n;
p << r.p;
c << r.c;
@@
let pieces = Str.split (Str.regexp "/") (List.hd p).file in
if not (List.mem f ignore) &&
List.for_all (fun x -> not (List.mem x pieces)) dignore
then
(if endnl c
then inc withnl (f,n)
else inc withoutnl (f,n))
@finalize:ocaml depends on !after_start@
w1 << merge.withnl;
w2 << merge.withoutnl;
@@
let names = ref [] in
let incn tbl k v =
let cell =
try Hashtbl.find tbl k
with Not_found ->
begin
let cell = ref 0 in
Hashtbl.add tbl k cell;
cell
end in
(if not (List.mem k !names) then names := k :: !names);
cell := !v + !cell in
List.iter (function w -> Hashtbl.iter (incn withnl) w) w1;
List.iter (function w -> Hashtbl.iter (incn withoutnl) w) w2;
List.iter
(function name ->
let wth = try !(Hashtbl.find withnl name) with _ -> 0 in
let wo = try !(Hashtbl.find withoutnl name) with _ -> 0 in
if wth > 0 && wth <= wo / 3 then Hashtbl.remove withnl name
else (Printf.eprintf "dropping %s %d %d\n" (fst name) wth wo; Hashtbl.remove withoutnl name; Hashtbl.remove withnl name))
!names;
let it = new iteration() in
it#add_virtual_rule After_start;
it#register()
@s1 depends on after_start@
constant char[] c;
expression list[n] es;
identifier f;
position p;
@@
f(es,c@p,...)
@script:ocaml s2@
f << s1.f;
n << s1.n;
c << s1.c;
newc;
@@
try
let _ = Hashtbl.find withnl (f,n) in
if endnl c
then Coccilib.include_match false
else newc :=
make_expr(clean_string (String.sub c 0 (String.length c - 1)) "\\n\"")
with Not_found ->
try
let _ = Hashtbl.find withoutnl (f,n) in
if endnl c
then newc :=
make_expr(clean_string (String.sub c 0 (String.length c - 3)) "\"")
else Coccilib.include_match false
with Not_found -> Coccilib.include_match false
@@
constant char[] s1.c;
position s1.p;
expression s2.newc;
@@
- c@p
+ newc
// </smpl>
---
arch/arm/mach-davinci/board-da850-evm.c | 4 ++--
drivers/block/DAC960.c | 4 ++--
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 12 ++++++++----
drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c | 2 +-
drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c | 2 +-
drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c | 2 +-
drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c | 2 +-
drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 3 ++-
drivers/s390/block/dasd_diag.c | 3 +--
drivers/scsi/hpsa.c | 2 +-
fs/dlm/plock.c | 3 +--
fs/ext2/super.c | 2 +-
fs/hpfs/dnode.c | 3 ++-
net/dccp/ackvec.c | 2 +-
net/openvswitch/conntrack.c | 4 ++--
tools/perf/tests/dso-data.c | 9 +++++----
16 files changed, 32 insertions(+), 27 deletions(-)
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 03/12] net: dccp: drop unneeded newline
2017-12-27 14:51 [PATCH 00/12] drop unneeded newline Julia Lawall
@ 2017-12-27 14:51 ` Julia Lawall
2018-01-02 18:50 ` David Miller
[not found] ` <1514386305-7402-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-01-02 13:52 ` [Cluster-devel] [PATCH 00/12] " Bob Peterson
2 siblings, 1 reply; 11+ messages in thread
From: Julia Lawall @ 2017-12-27 14:51 UTC (permalink / raw)
To: Gerrit Renker
Cc: kernel-janitors, David S. Miller, dccp, netdev, linux-kernel
DCCP_CRIT prints some other text and then a newline after the message
string, so the message string does not need to include a newline
explicitly. Done using Coccinelle.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
net/dccp/ackvec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
index 3de0d03..2a24f7d 100644
--- a/net/dccp/ackvec.c
+++ b/net/dccp/ackvec.c
@@ -228,7 +228,7 @@ static void dccp_ackvec_add_new(struct dccp_ackvec *av, u32 num_packets,
}
if (num_cells + dccp_ackvec_buflen(av) >= DCCPAV_MAX_ACKVEC_LEN) {
- DCCP_CRIT("Ack Vector buffer overflow: dropping old entries\n");
+ DCCP_CRIT("Ack Vector buffer overflow: dropping old entries");
av->av_overflow = true;
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 05/12] openvswitch: drop unneeded newline
[not found] ` <1514386305-7402-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
@ 2017-12-27 14:51 ` Julia Lawall
2018-01-02 18:50 ` David Miller
0 siblings, 1 reply; 11+ messages in thread
From: Julia Lawall @ 2017-12-27 14:51 UTC (permalink / raw)
To: Pravin Shelar
Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA, David S. Miller,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
OVS_NLERR prints a newline at the end of the message string, so the
message string does not need to include a newline explicitly. Done
using Coccinelle.
Signed-off-by: Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
---
net/openvswitch/conntrack.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index b27c5c6..62f36cc9 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -1266,14 +1266,14 @@ static int parse_nat(const struct nlattr *attr,
/* Do not allow flags if no type is given. */
if (info->range.flags) {
OVS_NLERR(log,
- "NAT flags may be given only when NAT range (SRC or DST) is also specified.\n"
+ "NAT flags may be given only when NAT range (SRC or DST) is also specified."
);
return -EINVAL;
}
info->nat = OVS_CT_NAT; /* NAT existing connections. */
} else if (!info->commit) {
OVS_NLERR(log,
- "NAT attributes may be specified only when CT COMMIT flag is also specified.\n"
+ "NAT attributes may be specified only when CT COMMIT flag is also specified."
);
return -EINVAL;
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline
2017-12-27 14:51 [PATCH 00/12] drop unneeded newline Julia Lawall
2017-12-27 14:51 ` [PATCH 03/12] net: dccp: " Julia Lawall
[not found] ` <1514386305-7402-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
@ 2018-01-02 13:52 ` Bob Peterson
2018-01-02 13:55 ` Julia Lawall
2018-01-02 13:56 ` Bob Peterson
2 siblings, 2 replies; 11+ messages in thread
From: Bob Peterson @ 2018-01-02 13:52 UTC (permalink / raw)
To: Julia Lawall
Cc: dev, linux-s390, linux-media, linux-scsi, dccp,
Alexander Shishkin, netdev, kernel-janitors, linux-kernel,
dri-devel, cluster-devel, amd-gfx, Namhyung Kim, linux-ext4,
Jiri Olsa, linux-arm-kernel, esc storagedev
----- Original Message -----
| Drop newline at the end of a message string when the printing function adds
| a newline.
Hi Julia,
NACK.
As much as it's a pain when searching the source code for output strings,
this patch set goes against the accepted Linux coding style document. See:
https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings
Regards,
Bob Peterson
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline
2018-01-02 13:52 ` [Cluster-devel] [PATCH 00/12] " Bob Peterson
@ 2018-01-02 13:55 ` Julia Lawall
2018-01-02 13:56 ` Bob Peterson
1 sibling, 0 replies; 11+ messages in thread
From: Julia Lawall @ 2018-01-02 13:55 UTC (permalink / raw)
To: Bob Peterson
Cc: Julia Lawall, dri-devel, dev, linux-s390, linux-scsi, dccp,
Alexander Shishkin, netdev, kernel-janitors, linux-kernel,
amd-gfx, cluster-devel, esc storagedev, Namhyung Kim, linux-ext4,
Jiri Olsa, linux-arm-kernel, linux-media
On Tue, 2 Jan 2018, Bob Peterson wrote:
> ----- Original Message -----
> | Drop newline at the end of a message string when the printing function adds
> | a newline.
>
> Hi Julia,
>
> NACK.
>
> As much as it's a pain when searching the source code for output strings,
> this patch set goes against the accepted Linux coding style document. See:
>
> https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings
I don't think that's the case:
"However, never break user-visible strings such as printk messages,
because that breaks the ability to grep for them."
julia
>
> Regards,
>
> Bob Peterson
> --
> 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] 11+ messages in thread
* Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline
2018-01-02 13:52 ` [Cluster-devel] [PATCH 00/12] " Bob Peterson
2018-01-02 13:55 ` Julia Lawall
@ 2018-01-02 13:56 ` Bob Peterson
[not found] ` <1019862289.2632779.1514901387442.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
1 sibling, 1 reply; 11+ messages in thread
From: Bob Peterson @ 2018-01-02 13:56 UTC (permalink / raw)
To: Julia Lawall
Cc: dev, linux-s390, linux-media, linux-scsi, dccp,
Alexander Shishkin, netdev, kernel-janitors, linux-kernel,
dri-devel, cluster-devel, amd-gfx, Namhyung Kim, linux-ext4,
Jiri Olsa, linux-arm-kernel, esc storagedev
----- Original Message -----
| ----- Original Message -----
| | Drop newline at the end of a message string when the printing function adds
| | a newline.
|
| Hi Julia,
|
| NACK.
|
| As much as it's a pain when searching the source code for output strings,
| this patch set goes against the accepted Linux coding style document. See:
|
| https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings
|
| Regards,
|
| Bob Peterson
|
|
Hm. I guess I stand corrected. The document reads:
"However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them."
Still, the GFS2 and DLM code has a plethora of broken-up printk messages,
and I don't like the thought of re-combining them all.
Regards,
Bob Peterson
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline
[not found] ` <1019862289.2632779.1514901387442.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2018-01-02 14:00 ` Julia Lawall
2018-01-02 15:11 ` Bart Van Assche
0 siblings, 1 reply; 11+ messages in thread
From: Julia Lawall @ 2018-01-02 14:00 UTC (permalink / raw)
To: Bob Peterson
Cc: dev-yBygre7rU0TnMu66kgdUjQ, linux-s390-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA, dccp-u79uwXL29TY76Z2rM5mHXA,
Alexander Shishkin, netdev-u79uwXL29TY76Z2rM5mHXA,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
cluster-devel-H+wXaHxf7aLQT0dZR+AlfA,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, esc storagedev,
Namhyung Kim, linux-ext4-u79uwXL29TY76Z2rM5mHXA, Jiri Olsa,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-media-u79uwXL29TY76Z2rM5mHXA
On Tue, 2 Jan 2018, Bob Peterson wrote:
> ----- Original Message -----
> | ----- Original Message -----
> | | Drop newline at the end of a message string when the printing function adds
> | | a newline.
> |
> | Hi Julia,
> |
> | NACK.
> |
> | As much as it's a pain when searching the source code for output strings,
> | this patch set goes against the accepted Linux coding style document. See:
> |
> | https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings
> |
> | Regards,
> |
> | Bob Peterson
> |
> |
> Hm. I guess I stand corrected. The document reads:
>
> "However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them."
>
> Still, the GFS2 and DLM code has a plethora of broken-up printk messages,
> and I don't like the thought of re-combining them all.
Actually, the point of the patch was to remove the unnecessary \n at the
end of the string, because log_print will add another one. If you prefer
to keep the string broken up, I can resend the patch in that form, but
without the unnecessary \n.
julia
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline
2018-01-02 14:00 ` Julia Lawall
@ 2018-01-02 15:11 ` Bart Van Assche
2018-01-02 15:16 ` Julia Lawall
0 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2018-01-02 15:11 UTC (permalink / raw)
To: rpeterso@redhat.com, julia.lawall@lip6.fr
Cc: kernel-janitors@vger.kernel.org, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org, jolsa@redhat.com,
linux-media@vger.kernel.org, amd-gfx@lists.freedesktop.org,
namhyung@kernel.org, linux-scsi@vger.kernel.org,
esc.storagedev@microsemi.com, dri-devel@lists.freedesktop.org,
alexander.shishkin@linux.intel.com, dev@openvswitch.org,
netdev@vger.kernel.org, "linux-arm-kernel@li
On Tue, 2018-01-02 at 15:00 +0100, Julia Lawall wrote:
> On Tue, 2 Jan 2018, Bob Peterson wrote:
> > ----- Original Message -----
> > > ----- Original Message -----
> > >
> > Still, the GFS2 and DLM code has a plethora of broken-up printk messages,
> > and I don't like the thought of re-combining them all.
>
> Actually, the point of the patch was to remove the unnecessary \n at the
> end of the string, because log_print will add another one. If you prefer
> to keep the string broken up, I can resend the patch in that form, but
> without the unnecessary \n.
Please combine any user-visible strings into a single line for which the
unneeded newline is dropped since these strings are modified anyway by
your patch.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline
2018-01-02 15:11 ` Bart Van Assche
@ 2018-01-02 15:16 ` Julia Lawall
0 siblings, 0 replies; 11+ messages in thread
From: Julia Lawall @ 2018-01-02 15:16 UTC (permalink / raw)
To: Bart Van Assche
Cc: dev@openvswitch.org, linux-s390@vger.kernel.org,
linux-scsi@vger.kernel.org, dccp@vger.kernel.org,
alexander.shishkin@linux.intel.com, esc.storagedev@microsemi.com,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
amd-gfx@lists.freedesktop.org, cluster-devel@redhat.com,
julia.lawall@lip6.fr, dri-devel@lists.freedesktop.org,
netdev@vger.kernel.org, rpeterso@redhat.com, namhyung@kernel.org,
"linux-ext4@vger.kernel.
On Tue, 2 Jan 2018, Bart Van Assche wrote:
> On Tue, 2018-01-02 at 15:00 +0100, Julia Lawall wrote:
> > On Tue, 2 Jan 2018, Bob Peterson wrote:
> > > ----- Original Message -----
> > > > ----- Original Message -----
> > > >
> > > Still, the GFS2 and DLM code has a plethora of broken-up printk messages,
> > > and I don't like the thought of re-combining them all.
> >
> > Actually, the point of the patch was to remove the unnecessary \n at the
> > end of the string, because log_print will add another one. If you prefer
> > to keep the string broken up, I can resend the patch in that form, but
> > without the unnecessary \n.
>
> Please combine any user-visible strings into a single line for which the
> unneeded newline is dropped since these strings are modified anyway by
> your patch.
That is what the submitted patch (2/12 specifically) did.
julia
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 03/12] net: dccp: drop unneeded newline
2017-12-27 14:51 ` [PATCH 03/12] net: dccp: " Julia Lawall
@ 2018-01-02 18:50 ` David Miller
0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2018-01-02 18:50 UTC (permalink / raw)
To: Julia.Lawall; +Cc: gerrit, kernel-janitors, dccp, netdev, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Wed, 27 Dec 2017 15:51:36 +0100
> DCCP_CRIT prints some other text and then a newline after the message
> string, so the message string does not need to include a newline
> explicitly. Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Applied.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 05/12] openvswitch: drop unneeded newline
2017-12-27 14:51 ` [PATCH 05/12] openvswitch: " Julia Lawall
@ 2018-01-02 18:50 ` David Miller
0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2018-01-02 18:50 UTC (permalink / raw)
To: Julia.Lawall; +Cc: pshelar, kernel-janitors, netdev, dev, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Wed, 27 Dec 2017 15:51:38 +0100
> OVS_NLERR prints a newline at the end of the message string, so the
> message string does not need to include a newline explicitly. Done
> using Coccinelle.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Applied.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-01-02 18:50 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-27 14:51 [PATCH 00/12] drop unneeded newline Julia Lawall
2017-12-27 14:51 ` [PATCH 03/12] net: dccp: " Julia Lawall
2018-01-02 18:50 ` David Miller
[not found] ` <1514386305-7402-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2017-12-27 14:51 ` [PATCH 05/12] openvswitch: " Julia Lawall
2018-01-02 18:50 ` David Miller
2018-01-02 13:52 ` [Cluster-devel] [PATCH 00/12] " Bob Peterson
2018-01-02 13:55 ` Julia Lawall
2018-01-02 13:56 ` Bob Peterson
[not found] ` <1019862289.2632779.1514901387442.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-01-02 14:00 ` Julia Lawall
2018-01-02 15:11 ` Bart Van Assche
2018-01-02 15:16 ` Julia Lawall
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).