aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-09-11 16:07:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-11 18:21:34 -0400
commit6798a8caaf64fa68b9ab2044e070fe4545034e03 (patch)
tree0703bb5ad58e92d21c00a69359ba962ba4928740
parentc9946c4208a3725e116c05180d93154eb406d451 (diff)
fs/seq_file: convert int seq_vprint/seq_printf/etc... returns to void
The seq_<foo> function return values were frequently misused. See: commit 1f33c41c03da ("seq_file: Rename seq_overflow() to seq_has_overflowed() and make public") All uses of these return values have been removed, so convert the return types to void. Miscellanea: o Move seq_put_decimal_<type> and seq_escape prototypes closer the other seq_vprintf prototypes o Reorder seq_putc and seq_puts to return early on overflow o Add argument names to seq_vprintf and seq_printf o Update the seq_escape kernel-doc o Convert a couple of leading spaces to tabs in seq_escape Signed-off-by: Joe Perches <joe@perches.com> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Mark Brown <broonie@kernel.org> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Joerg Roedel <jroedel@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/iommu/omap-iommu-debug.c3
-rw-r--r--fs/nsfs.c3
-rw-r--r--fs/seq_file.c70
-rw-r--r--include/linux/seq_file.h19
4 files changed, 45 insertions, 50 deletions
diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
index 0717aa96ce39..9bc20e2119a3 100644
--- a/drivers/iommu/omap-iommu-debug.c
+++ b/drivers/iommu/omap-iommu-debug.c
@@ -135,8 +135,9 @@ __dump_tlb_entries(struct omap_iommu *obj, struct cr_regs *crs, int num)
135static ssize_t iotlb_dump_cr(struct omap_iommu *obj, struct cr_regs *cr, 135static ssize_t iotlb_dump_cr(struct omap_iommu *obj, struct cr_regs *cr,
136 struct seq_file *s) 136 struct seq_file *s)
137{ 137{
138 return seq_printf(s, "%08x %08x %01x\n", cr->cam, cr->ram, 138 seq_printf(s, "%08x %08x %01x\n", cr->cam, cr->ram,
139 (cr->cam & MMU_CAM_P) ? 1 : 0); 139 (cr->cam & MMU_CAM_P) ? 1 : 0);
140 return 0;
140} 141}
141 142
142static size_t omap_dump_tlb_entries(struct omap_iommu *obj, struct seq_file *s) 143static size_t omap_dump_tlb_entries(struct omap_iommu *obj, struct seq_file *s)
diff --git a/fs/nsfs.c b/fs/nsfs.c
index e4905fbf3396..8f20d6016e20 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -142,7 +142,8 @@ static int nsfs_show_path(struct seq_file *seq, struct dentry *dentry)
142 struct inode *inode = d_inode(dentry); 142 struct inode *inode = d_inode(dentry);
143 const struct proc_ns_operations *ns_ops = dentry->d_fsdata; 143 const struct proc_ns_operations *ns_ops = dentry->d_fsdata;
144 144
145 return seq_printf(seq, "%s:[%lu]", ns_ops->name, inode->i_ino); 145 seq_printf(seq, "%s:[%lu]", ns_ops->name, inode->i_ino);
146 return 0;
146} 147}
147 148
148static const struct super_operations nsfs_ops = { 149static const struct super_operations nsfs_ops = {
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 263b125dbcf4..225586e141ca 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -372,16 +372,16 @@ EXPORT_SYMBOL(seq_release);
372 * @esc: set of characters that need escaping 372 * @esc: set of characters that need escaping
373 * 373 *
374 * Puts string into buffer, replacing each occurrence of character from 374 * Puts string into buffer, replacing each occurrence of character from
375 * @esc with usual octal escape. Returns 0 in case of success, -1 - in 375 * @esc with usual octal escape.
376 * case of overflow. 376 * Use seq_has_overflowed() to check for errors.
377 */ 377 */
378int seq_escape(struct seq_file *m, const char *s, const char *esc) 378void seq_escape(struct seq_file *m, const char *s, const char *esc)
379{ 379{
380 char *end = m->buf + m->size; 380 char *end = m->buf + m->size;
381 char *p; 381 char *p;
382 char c; 382 char c;
383 383
384 for (p = m->buf + m->count; (c = *s) != '\0' && p < end; s++) { 384 for (p = m->buf + m->count; (c = *s) != '\0' && p < end; s++) {
385 if (!strchr(esc, c)) { 385 if (!strchr(esc, c)) {
386 *p++ = c; 386 *p++ = c;
387 continue; 387 continue;
@@ -394,14 +394,13 @@ int seq_escape(struct seq_file *m, const char *s, const char *esc)
394 continue; 394 continue;
395 } 395 }
396 seq_set_overflow(m); 396 seq_set_overflow(m);
397 return -1; 397 return;
398 } 398 }
399 m->count = p - m->buf; 399 m->count = p - m->buf;
400 return 0;
401} 400}
402EXPORT_SYMBOL(seq_escape); 401EXPORT_SYMBOL(seq_escape);
403 402
404int seq_vprintf(struct seq_file *m, const char *f, va_list args) 403void seq_vprintf(struct seq_file *m, const char *f, va_list args)
405{ 404{
406 int len; 405 int len;
407 406
@@ -409,24 +408,20 @@ int seq_vprintf(struct seq_file *m, const char *f, va_list args)
409 len = vsnprintf(m->buf + m->count, m->size - m->count, f, args); 408 len = vsnprintf(m->buf + m->count, m->size - m->count, f, args);
410 if (m->count + len < m->size) { 409 if (m->count + len < m->size) {
411 m->count += len; 410 m->count += len;
412 return 0; 411 return;
413 } 412 }
414 } 413 }
415 seq_set_overflow(m); 414 seq_set_overflow(m);
416 return -1;
417} 415}
418EXPORT_SYMBOL(seq_vprintf); 416EXPORT_SYMBOL(seq_vprintf);
419 417
420int seq_printf(struct seq_file *m, const char *f, ...) 418void seq_printf(struct seq_file *m, const char *f, ...)
421{ 419{
422 int ret;
423 va_list args; 420 va_list args;
424 421
425 va_start(args, f); 422 va_start(args, f);
426 ret = seq_vprintf(m, f, args); 423 seq_vprintf(m, f, args);
427 va_end(args); 424 va_end(args);
428
429 return ret;
430} 425}
431EXPORT_SYMBOL(seq_printf); 426EXPORT_SYMBOL(seq_printf);
432 427
@@ -664,26 +659,25 @@ int seq_open_private(struct file *filp, const struct seq_operations *ops,
664} 659}
665EXPORT_SYMBOL(seq_open_private); 660EXPORT_SYMBOL(seq_open_private);
666 661
667int seq_putc(struct seq_file *m, char c) 662void seq_putc(struct seq_file *m, char c)
668{ 663{
669 if (m->count < m->size) { 664 if (m->count >= m->size)
670 m->buf[m->count++] = c; 665 return;
671 return 0; 666
672 } 667 m->buf[m->count++] = c;
673 return -1;
674} 668}
675EXPORT_SYMBOL(seq_putc); 669EXPORT_SYMBOL(seq_putc);
676 670
677int seq_puts(struct seq_file *m, const char *s) 671void seq_puts(struct seq_file *m, const char *s)
678{ 672{
679 int len = strlen(s); 673 int len = strlen(s);
680 if (m->count + len < m->size) { 674
681 memcpy(m->buf + m->count, s, len); 675 if (m->count + len >= m->size) {
682 m->count += len; 676 seq_set_overflow(m);
683 return 0; 677 return;
684 } 678 }
685 seq_set_overflow(m); 679 memcpy(m->buf + m->count, s, len);
686 return -1; 680 m->count += len;
687} 681}
688EXPORT_SYMBOL(seq_puts); 682EXPORT_SYMBOL(seq_puts);
689 683
@@ -694,8 +688,8 @@ EXPORT_SYMBOL(seq_puts);
694 * This routine is very quick when you show lots of numbers. 688 * This routine is very quick when you show lots of numbers.
695 * In usual cases, it will be better to use seq_printf(). It's easier to read. 689 * In usual cases, it will be better to use seq_printf(). It's easier to read.
696 */ 690 */
697int seq_put_decimal_ull(struct seq_file *m, char delimiter, 691void seq_put_decimal_ull(struct seq_file *m, char delimiter,
698 unsigned long long num) 692 unsigned long long num)
699{ 693{
700 int len; 694 int len;
701 695
@@ -707,35 +701,33 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter,
707 701
708 if (num < 10) { 702 if (num < 10) {
709 m->buf[m->count++] = num + '0'; 703 m->buf[m->count++] = num + '0';
710 return 0; 704 return;
711 } 705 }
712 706
713 len = num_to_str(m->buf + m->count, m->size - m->count, num); 707 len = num_to_str(m->buf + m->count, m->size - m->count, num);
714 if (!len) 708 if (!len)
715 goto overflow; 709 goto overflow;
716 m->count += len; 710 m->count += len;
717 return 0; 711 return;
712
718overflow: 713overflow:
719 seq_set_overflow(m); 714 seq_set_overflow(m);
720 return -1;
721} 715}
722EXPORT_SYMBOL(seq_put_decimal_ull); 716EXPORT_SYMBOL(seq_put_decimal_ull);
723 717
724int seq_put_decimal_ll(struct seq_file *m, char delimiter, 718void seq_put_decimal_ll(struct seq_file *m, char delimiter, long long num)
725 long long num)
726{ 719{
727 if (num < 0) { 720 if (num < 0) {
728 if (m->count + 3 >= m->size) { 721 if (m->count + 3 >= m->size) {
729 seq_set_overflow(m); 722 seq_set_overflow(m);
730 return -1; 723 return;
731 } 724 }
732 if (delimiter) 725 if (delimiter)
733 m->buf[m->count++] = delimiter; 726 m->buf[m->count++] = delimiter;
734 num = -num; 727 num = -num;
735 delimiter = '-'; 728 delimiter = '-';
736 } 729 }
737 return seq_put_decimal_ull(m, delimiter, num); 730 seq_put_decimal_ull(m, delimiter, num);
738
739} 731}
740EXPORT_SYMBOL(seq_put_decimal_ll); 732EXPORT_SYMBOL(seq_put_decimal_ll);
741 733
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index adeadbd6d7bf..dde00defbaa5 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -114,13 +114,18 @@ int seq_open(struct file *, const struct seq_operations *);
114ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); 114ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
115loff_t seq_lseek(struct file *, loff_t, int); 115loff_t seq_lseek(struct file *, loff_t, int);
116int seq_release(struct inode *, struct file *); 116int seq_release(struct inode *, struct file *);
117int seq_escape(struct seq_file *, const char *, const char *);
118int seq_putc(struct seq_file *m, char c);
119int seq_puts(struct seq_file *m, const char *s);
120int seq_write(struct seq_file *seq, const void *data, size_t len); 117int seq_write(struct seq_file *seq, const void *data, size_t len);
121 118
122__printf(2, 3) int seq_printf(struct seq_file *, const char *, ...); 119__printf(2, 0)
123__printf(2, 0) int seq_vprintf(struct seq_file *, const char *, va_list args); 120void seq_vprintf(struct seq_file *m, const char *fmt, va_list args);
121__printf(2, 3)
122void seq_printf(struct seq_file *m, const char *fmt, ...);
123void seq_putc(struct seq_file *m, char c);
124void seq_puts(struct seq_file *m, const char *s);
125void seq_put_decimal_ull(struct seq_file *m, char delimiter,
126 unsigned long long num);
127void seq_put_decimal_ll(struct seq_file *m, char delimiter, long long num);
128void seq_escape(struct seq_file *m, const char *s, const char *esc);
124 129
125void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type, 130void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,
126 int rowsize, int groupsize, const void *buf, size_t len, 131 int rowsize, int groupsize, const void *buf, size_t len,
@@ -138,10 +143,6 @@ int single_release(struct inode *, struct file *);
138void *__seq_open_private(struct file *, const struct seq_operations *, int); 143void *__seq_open_private(struct file *, const struct seq_operations *, int);
139int seq_open_private(struct file *, const struct seq_operations *, int); 144int seq_open_private(struct file *, const struct seq_operations *, int);
140int seq_release_private(struct inode *, struct file *); 145int seq_release_private(struct inode *, struct file *);
141int seq_put_decimal_ull(struct seq_file *m, char delimiter,
142 unsigned long long num);
143int seq_put_decimal_ll(struct seq_file *m, char delimiter,
144 long long num);
145 146
146static inline struct user_namespace *seq_user_ns(struct seq_file *seq) 147static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
147{ 148{