Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: lustre: lustre: libcfs: Replaced printk() with pr_err() and pr_cont()

The following checkpatch warning was fixed:

Prefer [subsystem eg: netdev]_err([subsystem]dev

with the help of Coccinelle. pr_cont() was used to replace those printk
statements which followed a printk that did not end with a '\n'. The following
semantic patch was used to replace printk() with pr_err():

@a@
expression e;
@@

printk(e,...);

@script:python b@
e << a.e;
y;
@@

import re
match = re.match('KERN_ERR ', e);
if (match == None):
cocci.include_match(False)

else:
m = re.sub('KERN_ERR ', '', e)
coccinelle.y = m;

@c@
expression a.e;
identifier b.y;
@@

- printk(e,
+ pr_err(y,
...);

Signed-off-by: Tina Johnson <tinajohnson.1234@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Tina Johnson and committed by
Greg Kroah-Hartman
324588ec 85b7a9de

+12 -14
+12 -14
drivers/staging/lustre/lustre/libcfs/tracefile.c
··· 224 224 */ 225 225 226 226 if (len > PAGE_CACHE_SIZE) { 227 - printk(KERN_ERR 228 - "cowardly refusing to write %lu bytes in a page\n", len); 227 + pr_err("cowardly refusing to write %lu bytes in a page\n", len); 229 228 return NULL; 230 229 } 231 230 ··· 687 688 if (IS_ERR(filp)) { 688 689 rc = PTR_ERR(filp); 689 690 filp = NULL; 690 - printk(KERN_ERR "LustreError: can't open %s for dump: rc %d\n", 691 - filename, rc); 691 + pr_err("LustreError: can't open %s for dump: rc %d\n", 692 + filename, rc); 692 693 goto out; 693 694 } 694 695 ··· 725 726 MMSPACE_CLOSE; 726 727 rc = vfs_fsync(filp, 1); 727 728 if (rc) 728 - printk(KERN_ERR "sync returns %d\n", rc); 729 + pr_err("sync returns %d\n", rc); 729 730 close: 730 731 filp_close(filp, NULL); 731 732 out: ··· 1047 1048 int i; 1048 1049 1049 1050 printk(KERN_ALERT "Lustre: trace pages aren't empty\n"); 1050 - printk(KERN_ERR "total cpus(%d): ", 1051 - num_possible_cpus()); 1051 + pr_err("total cpus(%d): ", 1052 + num_possible_cpus()); 1052 1053 for (i = 0; i < num_possible_cpus(); i++) 1053 1054 if (cpu_online(i)) 1054 - printk(KERN_ERR "%d(on) ", i); 1055 + pr_cont("%d(on) ", i); 1055 1056 else 1056 - printk(KERN_ERR "%d(off) ", i); 1057 - printk(KERN_ERR "\n"); 1057 + pr_cont("%d(off) ", i); 1058 + pr_cont("\n"); 1058 1059 1059 1060 i = 0; 1060 1061 list_for_each_entry_safe(tage, tmp, &pc.pc_pages, 1061 1062 linkage) 1062 - printk(KERN_ERR "page %d belongs to cpu %d\n", 1063 - ++i, tage->cpu); 1064 - printk(KERN_ERR "There are %d pages unwritten\n", 1065 - i); 1063 + pr_err("page %d belongs to cpu %d\n", 1064 + ++i, tage->cpu); 1065 + pr_err("There are %d pages unwritten\n", i); 1066 1066 } 1067 1067 __LASSERT(list_empty(&pc.pc_pages)); 1068 1068 end_loop: