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>
This commit is contained in:
Tetsuo Handa 2013-11-14 14:31:57 -08:00 committed by Linus Torvalds
parent 839cc2a94c
commit 652586df95
10 changed files with 73 additions and 97 deletions

View File

@ -29,7 +29,6 @@ static int show_console_dev(struct seq_file *m, void *v)
char flags[ARRAY_SIZE(con_flags) + 1]; char flags[ARRAY_SIZE(con_flags) + 1];
struct console *con = v; struct console *con = v;
unsigned int a; unsigned int a;
int len;
dev_t dev = 0; dev_t dev = 0;
if (con->device) { if (con->device) {
@ -47,11 +46,10 @@ static int show_console_dev(struct seq_file *m, void *v)
con_flags[a].name : ' '; con_flags[a].name : ' ';
flags[a] = 0; flags[a] = 0;
seq_printf(m, "%s%d%n", con->name, con->index, &len); seq_setwidth(m, 21 - 1);
len = 21 - len; seq_printf(m, "%s%d", con->name, con->index);
if (len < 1) seq_pad(m, ' ');
len = 1; seq_printf(m, "%c%c%c (%s)", con->read ? 'R' : '-',
seq_printf(m, "%*c%c%c%c (%s)", len, ' ', con->read ? 'R' : '-',
con->write ? 'W' : '-', con->unblank ? 'U' : '-', con->write ? 'W' : '-', con->unblank ? 'U' : '-',
flags); flags);
if (dev) if (dev)

View File

@ -39,7 +39,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
unsigned long ino = 0; unsigned long ino = 0;
struct file *file; struct file *file;
dev_t dev = 0; dev_t dev = 0;
int flags, len; int flags;
flags = region->vm_flags; flags = region->vm_flags;
file = region->vm_file; file = region->vm_file;
@ -50,8 +50,9 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
ino = inode->i_ino; ino = inode->i_ino;
} }
seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
seq_printf(m, seq_printf(m,
"%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
region->vm_start, region->vm_start,
region->vm_end, region->vm_end,
flags & VM_READ ? 'r' : '-', flags & VM_READ ? 'r' : '-',
@ -59,13 +60,10 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
flags & VM_EXEC ? 'x' : '-', flags & VM_EXEC ? 'x' : '-',
flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p', flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
((loff_t)region->vm_pgoff) << PAGE_SHIFT, ((loff_t)region->vm_pgoff) << PAGE_SHIFT,
MAJOR(dev), MINOR(dev), ino, &len); MAJOR(dev), MINOR(dev), ino);
if (file) { if (file) {
len = 25 + sizeof(void *) * 6 - len; seq_pad(m, ' ');
if (len < 1)
len = 1;
seq_printf(m, "%*c", len, ' ');
seq_path(m, &file->f_path, ""); seq_path(m, &file->f_path, "");
} }

View File

@ -84,14 +84,6 @@ unsigned long task_statm(struct mm_struct *mm,
return mm->total_vm; return mm->total_vm;
} }
static void pad_len_spaces(struct seq_file *m, int len)
{
len = 25 + sizeof(void*) * 6 - len;
if (len < 1)
len = 1;
seq_printf(m, "%*c", len, ' ');
}
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
/* /*
* These functions are for numa_maps but called in generic **maps seq_file * 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)
unsigned long long pgoff = 0; unsigned long long pgoff = 0;
unsigned long start, end; unsigned long start, end;
dev_t dev = 0; dev_t dev = 0;
int len;
const char *name = NULL; const char *name = NULL;
if (file) { if (file) {
@ -287,7 +278,8 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
if (stack_guard_page_end(vma, end)) if (stack_guard_page_end(vma, end))
end -= PAGE_SIZE; end -= PAGE_SIZE;
seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
start, start,
end, end,
flags & VM_READ ? 'r' : '-', flags & VM_READ ? 'r' : '-',
@ -295,14 +287,14 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
flags & VM_EXEC ? 'x' : '-', flags & VM_EXEC ? 'x' : '-',
flags & VM_MAYSHARE ? 's' : 'p', flags & VM_MAYSHARE ? 's' : 'p',
pgoff, pgoff,
MAJOR(dev), MINOR(dev), ino, &len); MAJOR(dev), MINOR(dev), ino);
/* /*
* Print the dentry name for named mappings, and a * Print the dentry name for named mappings, and a
* special [heap] marker for the heap: * special [heap] marker for the heap:
*/ */
if (file) { if (file) {
pad_len_spaces(m, len); seq_pad(m, ' ');
seq_path(m, &file->f_path, "\n"); seq_path(m, &file->f_path, "\n");
goto done; goto done;
} }
@ -334,7 +326,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
name = "[stack]"; name = "[stack]";
} else { } else {
/* Thread stack in /proc/PID/maps */ /* Thread stack in /proc/PID/maps */
pad_len_spaces(m, len); seq_pad(m, ' ');
seq_printf(m, "[stack:%d]", tid); seq_printf(m, "[stack:%d]", tid);
} }
} }
@ -342,7 +334,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
done: done:
if (name) { if (name) {
pad_len_spaces(m, len); seq_pad(m, ' ');
seq_puts(m, name); seq_puts(m, name);
} }
seq_putc(m, '\n'); seq_putc(m, '\n');

View File

@ -123,14 +123,6 @@ unsigned long task_statm(struct mm_struct *mm,
return size; return size;
} }
static void pad_len_spaces(struct seq_file *m, int len)
{
len = 25 + sizeof(void*) * 6 - len;
if (len < 1)
len = 1;
seq_printf(m, "%*c", len, ' ');
}
/* /*
* display a single VMA to a sequenced file * display a single VMA to a sequenced file
*/ */
@ -142,7 +134,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
unsigned long ino = 0; unsigned long ino = 0;
struct file *file; struct file *file;
dev_t dev = 0; dev_t dev = 0;
int flags, len; int flags;
unsigned long long pgoff = 0; unsigned long long pgoff = 0;
flags = vma->vm_flags; flags = vma->vm_flags;
@ -155,8 +147,9 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT; pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
} }
seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
seq_printf(m, seq_printf(m,
"%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
vma->vm_start, vma->vm_start,
vma->vm_end, vma->vm_end,
flags & VM_READ ? 'r' : '-', flags & VM_READ ? 'r' : '-',
@ -164,16 +157,16 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
flags & VM_EXEC ? 'x' : '-', flags & VM_EXEC ? 'x' : '-',
flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p', flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
pgoff, pgoff,
MAJOR(dev), MINOR(dev), ino, &len); MAJOR(dev), MINOR(dev), ino);
if (file) { if (file) {
pad_len_spaces(m, len); seq_pad(m, ' ');
seq_path(m, &file->f_path, ""); seq_path(m, &file->f_path, "");
} else if (mm) { } else if (mm) {
pid_t tid = vm_is_stack(priv->task, vma, is_pid); pid_t tid = vm_is_stack(priv->task, vma, is_pid);
if (tid != 0) { if (tid != 0) {
pad_len_spaces(m, len); seq_pad(m, ' ');
/* /*
* Thread stack in /proc/PID/task/TID/maps or * Thread stack in /proc/PID/task/TID/maps or
* the main process stack. * the main process stack.

View File

@ -2523,16 +2523,17 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
list_for_each_entry_rcu(fa, &li->falh, fa_list) { list_for_each_entry_rcu(fa, &li->falh, fa_list) {
const struct fib_info *fi = fa->fa_info; const struct fib_info *fi = fa->fa_info;
unsigned int flags = fib_flag_trans(fa->fa_type, mask, fi); unsigned int flags = fib_flag_trans(fa->fa_type, mask, fi);
int len;
if (fa->fa_type == RTN_BROADCAST if (fa->fa_type == RTN_BROADCAST
|| fa->fa_type == RTN_MULTICAST) || fa->fa_type == RTN_MULTICAST)
continue; continue;
seq_setwidth(seq, 127);
if (fi) if (fi)
seq_printf(seq, seq_printf(seq,
"%s\t%08X\t%08X\t%04X\t%d\t%u\t" "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
"%d\t%08X\t%d\t%u\t%u%n", "%d\t%08X\t%d\t%u\t%u",
fi->fib_dev ? fi->fib_dev->name : "*", fi->fib_dev ? fi->fib_dev->name : "*",
prefix, prefix,
fi->fib_nh->nh_gw, flags, 0, 0, fi->fib_nh->nh_gw, flags, 0, 0,
@ -2541,15 +2542,15 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
(fi->fib_advmss ? (fi->fib_advmss ?
fi->fib_advmss + 40 : 0), fi->fib_advmss + 40 : 0),
fi->fib_window, fi->fib_window,
fi->fib_rtt >> 3, &len); fi->fib_rtt >> 3);
else else
seq_printf(seq, seq_printf(seq,
"*\t%08X\t%08X\t%04X\t%d\t%u\t" "*\t%08X\t%08X\t%04X\t%d\t%u\t"
"%d\t%08X\t%d\t%u\t%u%n", "%d\t%08X\t%d\t%u\t%u",
prefix, 0, flags, 0, 0, 0, prefix, 0, flags, 0, 0, 0,
mask, 0, 0, 0, &len); mask, 0, 0, 0);
seq_printf(seq, "%*s\n", 127 - len, ""); seq_pad(seq, '\n');
} }
} }

View File

@ -1076,7 +1076,7 @@ void ping_seq_stop(struct seq_file *seq, void *v)
EXPORT_SYMBOL_GPL(ping_seq_stop); EXPORT_SYMBOL_GPL(ping_seq_stop);
static void ping_v4_format_sock(struct sock *sp, struct seq_file *f, static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
int bucket, int *len) int bucket)
{ {
struct inet_sock *inet = inet_sk(sp); struct inet_sock *inet = inet_sk(sp);
__be32 dest = inet->inet_daddr; __be32 dest = inet->inet_daddr;
@ -1085,7 +1085,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
__u16 srcp = ntohs(inet->inet_sport); __u16 srcp = ntohs(inet->inet_sport);
seq_printf(f, "%5d: %08X:%04X %08X:%04X" seq_printf(f, "%5d: %08X:%04X %08X:%04X"
" %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d%n", " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d",
bucket, src, srcp, dest, destp, sp->sk_state, bucket, src, srcp, dest, destp, sp->sk_state,
sk_wmem_alloc_get(sp), sk_wmem_alloc_get(sp),
sk_rmem_alloc_get(sp), sk_rmem_alloc_get(sp),
@ -1093,23 +1093,22 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)), from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
0, sock_i_ino(sp), 0, sock_i_ino(sp),
atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_refcnt), sp,
atomic_read(&sp->sk_drops), len); atomic_read(&sp->sk_drops));
} }
static int ping_v4_seq_show(struct seq_file *seq, void *v) static int ping_v4_seq_show(struct seq_file *seq, void *v)
{ {
seq_setwidth(seq, 127);
if (v == SEQ_START_TOKEN) if (v == SEQ_START_TOKEN)
seq_printf(seq, "%-127s\n", seq_puts(seq, " sl local_address rem_address st tx_queue "
" sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout " "rx_queue tr tm->when retrnsmt uid timeout "
"inode ref pointer drops"); "inode ref pointer drops");
else { else {
struct ping_iter_state *state = seq->private; struct ping_iter_state *state = seq->private;
int len;
ping_v4_format_sock(v, seq, state->bucket, &len); ping_v4_format_sock(v, seq, state->bucket);
seq_printf(seq, "%*s\n", 127 - len, "");
} }
seq_pad(seq, '\n');
return 0; return 0;
} }

View File

@ -2541,13 +2541,13 @@ void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo)
EXPORT_SYMBOL(tcp_proc_unregister); EXPORT_SYMBOL(tcp_proc_unregister);
static void get_openreq4(const struct sock *sk, const struct request_sock *req, static void get_openreq4(const struct sock *sk, const struct request_sock *req,
struct seq_file *f, int i, kuid_t uid, int *len) struct seq_file *f, int i, kuid_t uid)
{ {
const struct inet_request_sock *ireq = inet_rsk(req); const struct inet_request_sock *ireq = inet_rsk(req);
long delta = req->expires - jiffies; long delta = req->expires - jiffies;
seq_printf(f, "%4d: %08X:%04X %08X:%04X" seq_printf(f, "%4d: %08X:%04X %08X:%04X"
" %02X %08X:%08X %02X:%08lX %08X %5u %8d %u %d %pK%n", " %02X %08X:%08X %02X:%08lX %08X %5u %8d %u %d %pK",
i, i,
ireq->ir_loc_addr, ireq->ir_loc_addr,
ntohs(inet_sk(sk)->inet_sport), ntohs(inet_sk(sk)->inet_sport),
@ -2562,11 +2562,10 @@ static void get_openreq4(const struct sock *sk, const struct request_sock *req,
0, /* non standard timer */ 0, /* non standard timer */
0, /* open_requests have no inode */ 0, /* open_requests have no inode */
atomic_read(&sk->sk_refcnt), atomic_read(&sk->sk_refcnt),
req, req);
len);
} }
static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len) static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
{ {
int timer_active; int timer_active;
unsigned long timer_expires; unsigned long timer_expires;
@ -2605,7 +2604,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
rx_queue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0); rx_queue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0);
seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX " seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
"%08X %5u %8d %lu %d %pK %lu %lu %u %u %d%n", "%08X %5u %8d %lu %d %pK %lu %lu %u %u %d",
i, src, srcp, dest, destp, sk->sk_state, i, src, srcp, dest, destp, sk->sk_state,
tp->write_seq - tp->snd_una, tp->write_seq - tp->snd_una,
rx_queue, rx_queue,
@ -2622,12 +2621,11 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
tp->snd_cwnd, tp->snd_cwnd,
sk->sk_state == TCP_LISTEN ? sk->sk_state == TCP_LISTEN ?
(fastopenq ? fastopenq->max_qlen : 0) : (fastopenq ? fastopenq->max_qlen : 0) :
(tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh), (tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh));
len);
} }
static void get_timewait4_sock(const struct inet_timewait_sock *tw, static void get_timewait4_sock(const struct inet_timewait_sock *tw,
struct seq_file *f, int i, int *len) struct seq_file *f, int i)
{ {
__be32 dest, src; __be32 dest, src;
__u16 destp, srcp; __u16 destp, srcp;
@ -2639,10 +2637,10 @@ static void get_timewait4_sock(const struct inet_timewait_sock *tw,
srcp = ntohs(tw->tw_sport); srcp = ntohs(tw->tw_sport);
seq_printf(f, "%4d: %08X:%04X %08X:%04X" seq_printf(f, "%4d: %08X:%04X %08X:%04X"
" %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK%n", " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK",
i, src, srcp, dest, destp, tw->tw_substate, 0, 0, i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
3, jiffies_delta_to_clock_t(delta), 0, 0, 0, 0, 3, jiffies_delta_to_clock_t(delta), 0, 0, 0, 0,
atomic_read(&tw->tw_refcnt), tw, len); atomic_read(&tw->tw_refcnt), tw);
} }
#define TMPSZ 150 #define TMPSZ 150
@ -2651,11 +2649,10 @@ static int tcp4_seq_show(struct seq_file *seq, void *v)
{ {
struct tcp_iter_state *st; struct tcp_iter_state *st;
struct sock *sk = v; struct sock *sk = v;
int len;
seq_setwidth(seq, TMPSZ - 1);
if (v == SEQ_START_TOKEN) { if (v == SEQ_START_TOKEN) {
seq_printf(seq, "%-*s\n", TMPSZ - 1, seq_puts(seq, " sl local_address rem_address st tx_queue "
" sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout " "rx_queue tr tm->when retrnsmt uid timeout "
"inode"); "inode");
goto out; goto out;
@ -2666,16 +2663,16 @@ static int tcp4_seq_show(struct seq_file *seq, void *v)
case TCP_SEQ_STATE_LISTENING: case TCP_SEQ_STATE_LISTENING:
case TCP_SEQ_STATE_ESTABLISHED: case TCP_SEQ_STATE_ESTABLISHED:
if (sk->sk_state == TCP_TIME_WAIT) if (sk->sk_state == TCP_TIME_WAIT)
get_timewait4_sock(v, seq, st->num, &len); get_timewait4_sock(v, seq, st->num);
else else
get_tcp4_sock(v, seq, st->num, &len); get_tcp4_sock(v, seq, st->num);
break; break;
case TCP_SEQ_STATE_OPENREQ: case TCP_SEQ_STATE_OPENREQ:
get_openreq4(st->syn_wait_sk, v, seq, st->num, st->uid, &len); get_openreq4(st->syn_wait_sk, v, seq, st->num, st->uid);
break; break;
} }
seq_printf(seq, "%*s\n", TMPSZ - 1 - len, "");
out: out:
seq_pad(seq, '\n');
return 0; return 0;
} }

View File

@ -2331,7 +2331,7 @@ EXPORT_SYMBOL(udp_proc_unregister);
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static void udp4_format_sock(struct sock *sp, struct seq_file *f, static void udp4_format_sock(struct sock *sp, struct seq_file *f,
int bucket, int *len) int bucket)
{ {
struct inet_sock *inet = inet_sk(sp); struct inet_sock *inet = inet_sk(sp);
__be32 dest = inet->inet_daddr; __be32 dest = inet->inet_daddr;
@ -2340,7 +2340,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
__u16 srcp = ntohs(inet->inet_sport); __u16 srcp = ntohs(inet->inet_sport);
seq_printf(f, "%5d: %08X:%04X %08X:%04X" seq_printf(f, "%5d: %08X:%04X %08X:%04X"
" %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d%n", " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d",
bucket, src, srcp, dest, destp, sp->sk_state, bucket, src, srcp, dest, destp, sp->sk_state,
sk_wmem_alloc_get(sp), sk_wmem_alloc_get(sp),
sk_rmem_alloc_get(sp), sk_rmem_alloc_get(sp),
@ -2348,23 +2348,22 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)), from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
0, sock_i_ino(sp), 0, sock_i_ino(sp),
atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_refcnt), sp,
atomic_read(&sp->sk_drops), len); atomic_read(&sp->sk_drops));
} }
int udp4_seq_show(struct seq_file *seq, void *v) int udp4_seq_show(struct seq_file *seq, void *v)
{ {
seq_setwidth(seq, 127);
if (v == SEQ_START_TOKEN) if (v == SEQ_START_TOKEN)
seq_printf(seq, "%-127s\n", seq_puts(seq, " sl local_address rem_address st tx_queue "
" sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout " "rx_queue tr tm->when retrnsmt uid timeout "
"inode ref pointer drops"); "inode ref pointer drops");
else { else {
struct udp_iter_state *state = seq->private; struct udp_iter_state *state = seq->private;
int len;
udp4_format_sock(v, seq, state->bucket, &len); udp4_format_sock(v, seq, state->bucket);
seq_printf(seq, "%*s\n", 127 - len, "");
} }
seq_pad(seq, '\n');
return 0; return 0;
} }

View File

@ -595,26 +595,25 @@ static void pn_sock_seq_stop(struct seq_file *seq, void *v)
static int pn_sock_seq_show(struct seq_file *seq, void *v) static int pn_sock_seq_show(struct seq_file *seq, void *v)
{ {
int len; seq_setwidth(seq, 127);
if (v == SEQ_START_TOKEN) if (v == SEQ_START_TOKEN)
seq_printf(seq, "%s%n", "pt loc rem rs st tx_queue rx_queue " seq_puts(seq, "pt loc rem rs st tx_queue rx_queue "
" uid inode ref pointer drops", &len); " uid inode ref pointer drops");
else { else {
struct sock *sk = v; struct sock *sk = v;
struct pn_sock *pn = pn_sk(sk); struct pn_sock *pn = pn_sk(sk);
seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu " seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu "
"%d %pK %d%n", "%d %pK %d",
sk->sk_protocol, pn->sobject, pn->dobject, sk->sk_protocol, pn->sobject, pn->dobject,
pn->resource, sk->sk_state, pn->resource, sk->sk_state,
sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk), sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)), from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
sock_i_ino(sk), sock_i_ino(sk),
atomic_read(&sk->sk_refcnt), sk, atomic_read(&sk->sk_refcnt), sk,
atomic_read(&sk->sk_drops), &len); atomic_read(&sk->sk_drops));
} }
seq_printf(seq, "%*s\n", 127 - len, ""); seq_pad(seq, '\n');
return 0; return 0;
} }
@ -785,20 +784,19 @@ static void pn_res_seq_stop(struct seq_file *seq, void *v)
static int pn_res_seq_show(struct seq_file *seq, void *v) static int pn_res_seq_show(struct seq_file *seq, void *v)
{ {
int len; seq_setwidth(seq, 63);
if (v == SEQ_START_TOKEN) if (v == SEQ_START_TOKEN)
seq_printf(seq, "%s%n", "rs uid inode", &len); seq_puts(seq, "rs uid inode");
else { else {
struct sock **psk = v; struct sock **psk = v;
struct sock *sk = *psk; struct sock *sk = *psk;
seq_printf(seq, "%02X %5u %lu%n", seq_printf(seq, "%02X %5u %lu",
(int) (psk - pnres.sk), (int) (psk - pnres.sk),
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)), from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
sock_i_ino(sk), &len); sock_i_ino(sk));
} }
seq_printf(seq, "%*s\n", 63 - len, ""); seq_pad(seq, '\n');
return 0; return 0;
} }

View File

@ -79,12 +79,13 @@ static sctp_dbg_objcnt_entry_t sctp_dbg_objcnt[] = {
*/ */
static int sctp_objcnt_seq_show(struct seq_file *seq, void *v) static int sctp_objcnt_seq_show(struct seq_file *seq, void *v)
{ {
int i, len; int i;
i = (int)*(loff_t *)v; i = (int)*(loff_t *)v;
seq_printf(seq, "%s: %d%n", sctp_dbg_objcnt[i].label, seq_setwidth(seq, 127);
atomic_read(sctp_dbg_objcnt[i].counter), &len); seq_printf(seq, "%s: %d", sctp_dbg_objcnt[i].label,
seq_printf(seq, "%*s\n", 127 - len, ""); atomic_read(sctp_dbg_objcnt[i].counter));
seq_pad(seq, '\n');
return 0; return 0;
} }