aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2013-11-14 17:31:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-14 19:32:20 -0500
commit652586df95e5d76b37d07a11839126dcfede1621 (patch)
treee3a668265cade256302830ea3ff8b3699ab2977e /fs/proc
parent839cc2a94cc3665bafe32203c2f095f4dd470a80 (diff)
seq_file: remove "%n" usage from seq_file users
All seq_printf() users are using "%n" for calculating padding size, convert them to use seq_setwidth() / seq_pad() pair. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Joe Perches <joe@perches.com> Cc: David Miller <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/consoles.c10
-rw-r--r--fs/proc/nommu.c12
-rw-r--r--fs/proc/task_mmu.c20
-rw-r--r--fs/proc/task_nommu.c19
4 files changed, 21 insertions, 40 deletions
diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c
index b701eaa482bf..51942d5abcec 100644
--- a/fs/proc/consoles.c
+++ b/fs/proc/consoles.c
@@ -29,7 +29,6 @@ static int show_console_dev(struct seq_file *m, void *v)
29 char flags[ARRAY_SIZE(con_flags) + 1]; 29 char flags[ARRAY_SIZE(con_flags) + 1];
30 struct console *con = v; 30 struct console *con = v;
31 unsigned int a; 31 unsigned int a;
32 int len;
33 dev_t dev = 0; 32 dev_t dev = 0;
34 33
35 if (con->device) { 34 if (con->device) {
@@ -47,11 +46,10 @@ static int show_console_dev(struct seq_file *m, void *v)
47 con_flags[a].name : ' '; 46 con_flags[a].name : ' ';
48 flags[a] = 0; 47 flags[a] = 0;
49 48
50 seq_printf(m, "%s%d%n", con->name, con->index, &len); 49 seq_setwidth(m, 21 - 1);
51 len = 21 - len; 50 seq_printf(m, "%s%d", con->name, con->index);
52 if (len < 1) 51 seq_pad(m, ' ');
53 len = 1; 52 seq_printf(m, "%c%c%c (%s)", con->read ? 'R' : '-',
54 seq_printf(m, "%*c%c%c%c (%s)", len, ' ', con->read ? 'R' : '-',
55 con->write ? 'W' : '-', con->unblank ? 'U' : '-', 53 con->write ? 'W' : '-', con->unblank ? 'U' : '-',
56 flags); 54 flags);
57 if (dev) 55 if (dev)
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index ccfd99bd1c5a..5f9bc8a746c9 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -39,7 +39,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
39 unsigned long ino = 0; 39 unsigned long ino = 0;
40 struct file *file; 40 struct file *file;
41 dev_t dev = 0; 41 dev_t dev = 0;
42 int flags, len; 42 int flags;
43 43
44 flags = region->vm_flags; 44 flags = region->vm_flags;
45 file = region->vm_file; 45 file = region->vm_file;
@@ -50,8 +50,9 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
50 ino = inode->i_ino; 50 ino = inode->i_ino;
51 } 51 }
52 52
53 seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
53 seq_printf(m, 54 seq_printf(m,
54 "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", 55 "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
55 region->vm_start, 56 region->vm_start,
56 region->vm_end, 57 region->vm_end,
57 flags & VM_READ ? 'r' : '-', 58 flags & VM_READ ? 'r' : '-',
@@ -59,13 +60,10 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59 flags & VM_EXEC ? 'x' : '-', 60 flags & VM_EXEC ? 'x' : '-',
60 flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p', 61 flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
61 ((loff_t)region->vm_pgoff) << PAGE_SHIFT, 62 ((loff_t)region->vm_pgoff) << PAGE_SHIFT,
62 MAJOR(dev), MINOR(dev), ino, &len); 63 MAJOR(dev), MINOR(dev), ino);
63 64
64 if (file) { 65 if (file) {
65 len = 25 + sizeof(void *) * 6 - len; 66 seq_pad(m, ' ');
66 if (len < 1)
67 len = 1;
68 seq_printf(m, "%*c", len, ' ');
69 seq_path(m, &file->f_path, ""); 67 seq_path(m, &file->f_path, "");
70 } 68 }
71 69
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 42b5cf5d0326..fb52b548080d 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -84,14 +84,6 @@ unsigned long task_statm(struct mm_struct *mm,
84 return mm->total_vm; 84 return mm->total_vm;
85} 85}
86 86
87static void pad_len_spaces(struct seq_file *m, int len)
88{
89 len = 25 + sizeof(void*) * 6 - len;
90 if (len < 1)
91 len = 1;
92 seq_printf(m, "%*c", len, ' ');
93}
94
95#ifdef CONFIG_NUMA 87#ifdef CONFIG_NUMA
96/* 88/*
97 * These functions are for numa_maps but called in generic **maps seq_file 89 * These functions are for numa_maps but called in generic **maps seq_file
@@ -269,7 +261,6 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
269 unsigned long long pgoff = 0; 261 unsigned long long pgoff = 0;
270 unsigned long start, end; 262 unsigned long start, end;
271 dev_t dev = 0; 263 dev_t dev = 0;
272 int len;
273 const char *name = NULL; 264 const char *name = NULL;
274 265
275 if (file) { 266 if (file) {
@@ -287,7 +278,8 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
287 if (stack_guard_page_end(vma, end)) 278 if (stack_guard_page_end(vma, end))
288 end -= PAGE_SIZE; 279 end -= PAGE_SIZE;
289 280
290 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", 281 seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
282 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
291 start, 283 start,
292 end, 284 end,
293 flags & VM_READ ? 'r' : '-', 285 flags & VM_READ ? 'r' : '-',
@@ -295,14 +287,14 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
295 flags & VM_EXEC ? 'x' : '-', 287 flags & VM_EXEC ? 'x' : '-',
296 flags & VM_MAYSHARE ? 's' : 'p', 288 flags & VM_MAYSHARE ? 's' : 'p',
297 pgoff, 289 pgoff,
298 MAJOR(dev), MINOR(dev), ino, &len); 290 MAJOR(dev), MINOR(dev), ino);
299 291
300 /* 292 /*
301 * Print the dentry name for named mappings, and a 293 * Print the dentry name for named mappings, and a
302 * special [heap] marker for the heap: 294 * special [heap] marker for the heap:
303 */ 295 */
304 if (file) { 296 if (file) {
305 pad_len_spaces(m, len); 297 seq_pad(m, ' ');
306 seq_path(m, &file->f_path, "\n"); 298 seq_path(m, &file->f_path, "\n");
307 goto done; 299 goto done;
308 } 300 }
@@ -334,7 +326,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
334 name = "[stack]"; 326 name = "[stack]";
335 } else { 327 } else {
336 /* Thread stack in /proc/PID/maps */ 328 /* Thread stack in /proc/PID/maps */
337 pad_len_spaces(m, len); 329 seq_pad(m, ' ');
338 seq_printf(m, "[stack:%d]", tid); 330 seq_printf(m, "[stack:%d]", tid);
339 } 331 }
340 } 332 }
@@ -342,7 +334,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
342 334
343done: 335done:
344 if (name) { 336 if (name) {
345 pad_len_spaces(m, len); 337 seq_pad(m, ' ');
346 seq_puts(m, name); 338 seq_puts(m, name);
347 } 339 }
348 seq_putc(m, '\n'); 340 seq_putc(m, '\n');
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 56123a6f462e..678455d2d683 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -123,14 +123,6 @@ unsigned long task_statm(struct mm_struct *mm,
123 return size; 123 return size;
124} 124}
125 125
126static void pad_len_spaces(struct seq_file *m, int len)
127{
128 len = 25 + sizeof(void*) * 6 - len;
129 if (len < 1)
130 len = 1;
131 seq_printf(m, "%*c", len, ' ');
132}
133
134/* 126/*
135 * display a single VMA to a sequenced file 127 * display a single VMA to a sequenced file
136 */ 128 */
@@ -142,7 +134,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
142 unsigned long ino = 0; 134 unsigned long ino = 0;
143 struct file *file; 135 struct file *file;
144 dev_t dev = 0; 136 dev_t dev = 0;
145 int flags, len; 137 int flags;
146 unsigned long long pgoff = 0; 138 unsigned long long pgoff = 0;
147 139
148 flags = vma->vm_flags; 140 flags = vma->vm_flags;
@@ -155,8 +147,9 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
155 pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT; 147 pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
156 } 148 }
157 149
150 seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
158 seq_printf(m, 151 seq_printf(m,
159 "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", 152 "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
160 vma->vm_start, 153 vma->vm_start,
161 vma->vm_end, 154 vma->vm_end,
162 flags & VM_READ ? 'r' : '-', 155 flags & VM_READ ? 'r' : '-',
@@ -164,16 +157,16 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
164 flags & VM_EXEC ? 'x' : '-', 157 flags & VM_EXEC ? 'x' : '-',
165 flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p', 158 flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
166 pgoff, 159 pgoff,
167 MAJOR(dev), MINOR(dev), ino, &len); 160 MAJOR(dev), MINOR(dev), ino);
168 161
169 if (file) { 162 if (file) {
170 pad_len_spaces(m, len); 163 seq_pad(m, ' ');
171 seq_path(m, &file->f_path, ""); 164 seq_path(m, &file->f_path, "");
172 } else if (mm) { 165 } else if (mm) {
173 pid_t tid = vm_is_stack(priv->task, vma, is_pid); 166 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
174 167
175 if (tid != 0) { 168 if (tid != 0) {
176 pad_len_spaces(m, len); 169 seq_pad(m, ' ');
177 /* 170 /*
178 * Thread stack in /proc/PID/task/TID/maps or 171 * Thread stack in /proc/PID/task/TID/maps or
179 * the main process stack. 172 * the main process stack.