Commit 87ebdc00 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

fs/proc: clean up printks

- use pr_foo() throughout

- remove a couple of duplicated KERN_WARNINGs, via WARN(KERN_WARNING "...")

- nuke a few warnings which I've never seen happen, ever.

Cc: Joe Perches <joe@perches.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e579d2c2
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#include <linux/security.h> #include <linux/security.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/tracehook.h> #include <linux/tracehook.h>
#include <linux/printk.h>
#include <linux/cgroup.h> #include <linux/cgroup.h>
#include <linux/cpuset.h> #include <linux/cpuset.h>
#include <linux/audit.h> #include <linux/audit.h>
...@@ -952,7 +953,7 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf, ...@@ -952,7 +953,7 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf,
* /proc/pid/oom_adj is provided for legacy purposes, ask users to use * /proc/pid/oom_adj is provided for legacy purposes, ask users to use
* /proc/pid/oom_score_adj instead. * /proc/pid/oom_score_adj instead.
*/ */
printk_once(KERN_WARNING "%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n", pr_warn_once("%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n",
current->comm, task_pid_nr(current), task_pid_nr(task), current->comm, task_pid_nr(current), task_pid_nr(task),
task_pid_nr(task)); task_pid_nr(task));
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/printk.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/idr.h> #include <linux/idr.h>
...@@ -132,11 +133,8 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes, ...@@ -132,11 +133,8 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes,
} }
if (start == NULL) { if (start == NULL) {
if (n > PAGE_SIZE) { if (n > PAGE_SIZE) /* Apparent buffer overflow */
printk(KERN_ERR
"proc_file_read: Apparent buffer overflow!\n");
n = PAGE_SIZE; n = PAGE_SIZE;
}
n -= *ppos; n -= *ppos;
if (n <= 0) if (n <= 0)
break; break;
...@@ -144,26 +142,19 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes, ...@@ -144,26 +142,19 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes,
n = count; n = count;
start = page + *ppos; start = page + *ppos;
} else if (start < page) { } else if (start < page) {
if (n > PAGE_SIZE) { if (n > PAGE_SIZE) /* Apparent buffer overflow */
printk(KERN_ERR
"proc_file_read: Apparent buffer overflow!\n");
n = PAGE_SIZE; n = PAGE_SIZE;
}
if (n > count) { if (n > count) {
/* /*
* Don't reduce n because doing so might * Don't reduce n because doing so might
* cut off part of a data block. * cut off part of a data block.
*/ */
printk(KERN_WARNING pr_warn("proc_file_read: count exceeded\n");
"proc_file_read: Read count exceeded\n");
} }
} else /* start >= page */ { } else /* start >= page */ {
unsigned long startoff = (unsigned long)(start - page); unsigned long startoff = (unsigned long)(start - page);
if (n > (PAGE_SIZE - startoff)) { if (n > (PAGE_SIZE - startoff)) /* buffer overflow? */
printk(KERN_ERR
"proc_file_read: Apparent buffer overflow!\n");
n = PAGE_SIZE - startoff; n = PAGE_SIZE - startoff;
}
if (n > count) if (n > count)
n = count; n = count;
} }
...@@ -569,7 +560,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp ...@@ -569,7 +560,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
for (tmp = dir->subdir; tmp; tmp = tmp->next) for (tmp = dir->subdir; tmp; tmp = tmp->next)
if (strcmp(tmp->name, dp->name) == 0) { if (strcmp(tmp->name, dp->name) == 0) {
WARN(1, KERN_WARNING "proc_dir_entry '%s/%s' already registered\n", WARN(1, "proc_dir_entry '%s/%s' already registered\n",
dir->name, dp->name); dir->name, dp->name);
break; break;
} }
...@@ -830,9 +821,9 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent) ...@@ -830,9 +821,9 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
if (S_ISDIR(de->mode)) if (S_ISDIR(de->mode))
parent->nlink--; parent->nlink--;
de->nlink = 0; de->nlink = 0;
WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory " WARN(de->subdir, "%s: removing non-empty directory "
"'%s/%s', leaking at least '%s'\n", __func__, "'%s/%s', leaking at least '%s'\n", __func__,
de->parent->name, de->name, de->subdir->name); de->parent->name, de->name, de->subdir->name);
pde_put(de); pde_put(de);
} }
EXPORT_SYMBOL(remove_proc_entry); EXPORT_SYMBOL(remove_proc_entry);
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/printk.h>
#include <linux/file.h> #include <linux/file.h>
#include <linux/limits.h> #include <linux/limits.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -495,13 +496,13 @@ int proc_fill_super(struct super_block *s) ...@@ -495,13 +496,13 @@ int proc_fill_super(struct super_block *s)
pde_get(&proc_root); pde_get(&proc_root);
root_inode = proc_get_inode(s, &proc_root); root_inode = proc_get_inode(s, &proc_root);
if (!root_inode) { if (!root_inode) {
printk(KERN_ERR "proc_fill_super: get root inode failed\n"); pr_err("proc_fill_super: get root inode failed\n");
return -ENOMEM; return -ENOMEM;
} }
s->s_root = d_make_root(root_inode); s->s_root = d_make_root(root_inode);
if (!s->s_root) { if (!s->s_root) {
printk(KERN_ERR "proc_fill_super: allocate dentry failed\n"); pr_err("proc_fill_super: allocate dentry failed\n");
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/elfcore.h> #include <linux/elfcore.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/printk.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -619,7 +620,7 @@ static int __init proc_kcore_init(void) ...@@ -619,7 +620,7 @@ static int __init proc_kcore_init(void)
proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, proc_root_kcore = proc_create("kcore", S_IRUSR, NULL,
&proc_kcore_operations); &proc_kcore_operations);
if (!proc_root_kcore) { if (!proc_root_kcore) {
printk(KERN_ERR "couldn't create /proc/kcore\n"); pr_err("couldn't create /proc/kcore\n");
return 0; /* Always returns 0. */ return 0; /* Always returns 0. */
} }
/* Store text area if it's special */ /* Store text area if it's special */
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/time.h> #include <linux/time.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/printk.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -110,8 +111,8 @@ void proc_device_tree_update_prop(struct proc_dir_entry *pde, ...@@ -110,8 +111,8 @@ void proc_device_tree_update_prop(struct proc_dir_entry *pde,
if (ent->data == oldprop) if (ent->data == oldprop)
break; break;
if (ent == NULL) { if (ent == NULL) {
printk(KERN_WARNING "device-tree: property \"%s\" " pr_warn("device-tree: property \"%s\" does not exist\n",
" does not exist\n", oldprop->name); oldprop->name);
} else { } else {
ent->data = newprop; ent->data = newprop;
ent->size = newprop->length; ent->size = newprop->length;
...@@ -153,8 +154,8 @@ static const char *fixup_name(struct device_node *np, struct proc_dir_entry *de, ...@@ -153,8 +154,8 @@ static const char *fixup_name(struct device_node *np, struct proc_dir_entry *de,
realloc: realloc:
fixed_name = kmalloc(fixup_len, GFP_KERNEL); fixed_name = kmalloc(fixup_len, GFP_KERNEL);
if (fixed_name == NULL) { if (fixed_name == NULL) {
printk(KERN_ERR "device-tree: Out of memory trying to fixup " pr_err("device-tree: Out of memory trying to fixup "
"name \"%s\"\n", name); "name \"%s\"\n", name);
return name; return name;
} }
...@@ -175,8 +176,8 @@ static const char *fixup_name(struct device_node *np, struct proc_dir_entry *de, ...@@ -175,8 +176,8 @@ static const char *fixup_name(struct device_node *np, struct proc_dir_entry *de,
goto retry; goto retry;
} }
printk(KERN_WARNING "device-tree: Duplicate name in %s, " pr_warn("device-tree: Duplicate name in %s, renamed to \"%s\"\n",
"renamed to \"%s\"\n", np->full_name, fixed_name); np->full_name, fixed_name);
return fixed_name; return fixed_name;
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/printk.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/namei.h> #include <linux/namei.h>
...@@ -57,7 +58,7 @@ static void sysctl_print_dir(struct ctl_dir *dir) ...@@ -57,7 +58,7 @@ static void sysctl_print_dir(struct ctl_dir *dir)
{ {
if (dir->header.parent) if (dir->header.parent)
sysctl_print_dir(dir->header.parent); sysctl_print_dir(dir->header.parent);
printk(KERN_CONT "%s/", dir->header.ctl_table[0].procname); pr_cont("%s/", dir->header.ctl_table[0].procname);
} }
static int namecmp(const char *name1, int len1, const char *name2, int len2) static int namecmp(const char *name1, int len1, const char *name2, int len2)
...@@ -134,9 +135,9 @@ static int insert_entry(struct ctl_table_header *head, struct ctl_table *entry) ...@@ -134,9 +135,9 @@ static int insert_entry(struct ctl_table_header *head, struct ctl_table *entry)
else if (cmp > 0) else if (cmp > 0)
p = &(*p)->rb_right; p = &(*p)->rb_right;
else { else {
printk(KERN_ERR "sysctl duplicate entry: "); pr_err("sysctl duplicate entry: ");
sysctl_print_dir(head->parent); sysctl_print_dir(head->parent);
printk(KERN_CONT "/%s\n", entry->procname); pr_cont("/%s\n", entry->procname);
return -EEXIST; return -EEXIST;
} }
} }
...@@ -927,9 +928,9 @@ static struct ctl_dir *get_subdir(struct ctl_dir *dir, ...@@ -927,9 +928,9 @@ static struct ctl_dir *get_subdir(struct ctl_dir *dir,
subdir->header.nreg++; subdir->header.nreg++;
failed: failed:
if (unlikely(IS_ERR(subdir))) { if (unlikely(IS_ERR(subdir))) {
printk(KERN_ERR "sysctl could not get directory: "); pr_err("sysctl could not get directory: ");
sysctl_print_dir(dir); sysctl_print_dir(dir);
printk(KERN_CONT "/%*.*s %ld\n", pr_cont("/%*.*s %ld\n",
namelen, namelen, name, PTR_ERR(subdir)); namelen, namelen, name, PTR_ERR(subdir));
} }
drop_sysctl_table(&dir->header); drop_sysctl_table(&dir->header);
...@@ -995,8 +996,8 @@ static int sysctl_err(const char *path, struct ctl_table *table, char *fmt, ...) ...@@ -995,8 +996,8 @@ static int sysctl_err(const char *path, struct ctl_table *table, char *fmt, ...)
vaf.fmt = fmt; vaf.fmt = fmt;
vaf.va = &args; vaf.va = &args;
printk(KERN_ERR "sysctl table check failed: %s/%s %pV\n", pr_err("sysctl table check failed: %s/%s %pV\n",
path, table->procname, &vaf); path, table->procname, &vaf);
va_end(args); va_end(args);
return -EINVAL; return -EINVAL;
...@@ -1510,9 +1511,9 @@ static void put_links(struct ctl_table_header *header) ...@@ -1510,9 +1511,9 @@ static void put_links(struct ctl_table_header *header)
drop_sysctl_table(link_head); drop_sysctl_table(link_head);
} }
else { else {
printk(KERN_ERR "sysctl link missing during unregister: "); pr_err("sysctl link missing during unregister: ");
sysctl_print_dir(parent); sysctl_print_dir(parent);
printk(KERN_CONT "/%s\n", name); pr_cont("/%s\n", name);
} }
} }
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/printk.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/crash_dump.h> #include <linux/crash_dump.h>
...@@ -553,8 +554,7 @@ static int __init parse_crash_elf64_headers(void) ...@@ -553,8 +554,7 @@ static int __init parse_crash_elf64_headers(void)
ehdr.e_ehsize != sizeof(Elf64_Ehdr) || ehdr.e_ehsize != sizeof(Elf64_Ehdr) ||
ehdr.e_phentsize != sizeof(Elf64_Phdr) || ehdr.e_phentsize != sizeof(Elf64_Phdr) ||
ehdr.e_phnum == 0) { ehdr.e_phnum == 0) {
printk(KERN_WARNING "Warning: Core image elf header is not" pr_warn("Warning: Core image elf header is not sane\n");
"sane\n");
return -EINVAL; return -EINVAL;
} }
...@@ -609,8 +609,7 @@ static int __init parse_crash_elf32_headers(void) ...@@ -609,8 +609,7 @@ static int __init parse_crash_elf32_headers(void)
ehdr.e_ehsize != sizeof(Elf32_Ehdr) || ehdr.e_ehsize != sizeof(Elf32_Ehdr) ||
ehdr.e_phentsize != sizeof(Elf32_Phdr) || ehdr.e_phentsize != sizeof(Elf32_Phdr) ||
ehdr.e_phnum == 0) { ehdr.e_phnum == 0) {
printk(KERN_WARNING "Warning: Core image elf header is not" pr_warn("Warning: Core image elf header is not sane\n");
"sane\n");
return -EINVAL; return -EINVAL;
} }
...@@ -653,8 +652,7 @@ static int __init parse_crash_elf_headers(void) ...@@ -653,8 +652,7 @@ static int __init parse_crash_elf_headers(void)
if (rc < 0) if (rc < 0)
return rc; return rc;
if (memcmp(e_ident, ELFMAG, SELFMAG) != 0) { if (memcmp(e_ident, ELFMAG, SELFMAG) != 0) {
printk(KERN_WARNING "Warning: Core image elf header" pr_warn("Warning: Core image elf header not found\n");
" not found\n");
return -EINVAL; return -EINVAL;
} }
...@@ -673,8 +671,7 @@ static int __init parse_crash_elf_headers(void) ...@@ -673,8 +671,7 @@ static int __init parse_crash_elf_headers(void)
/* Determine vmcore size. */ /* Determine vmcore size. */
vmcore_size = get_vmcore_size_elf32(elfcorebuf); vmcore_size = get_vmcore_size_elf32(elfcorebuf);
} else { } else {
printk(KERN_WARNING "Warning: Core image elf header is not" pr_warn("Warning: Core image elf header is not sane\n");
" sane\n");
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
...@@ -690,7 +687,7 @@ static int __init vmcore_init(void) ...@@ -690,7 +687,7 @@ static int __init vmcore_init(void)
return rc; return rc;
rc = parse_crash_elf_headers(); rc = parse_crash_elf_headers();
if (rc) { if (rc) {
printk(KERN_WARNING "Kdump: vmcore not initialized\n"); pr_warn("Kdump: vmcore not initialized\n");
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment