forked from Minki/linux
include/trace/events/writeback.h: fix -Wstringop-truncation warnings
There are many of those warnings. In file included from ./arch/powerpc/include/asm/paca.h:15, from ./arch/powerpc/include/asm/current.h:13, from ./include/linux/thread_info.h:21, from ./include/asm-generic/preempt.h:5, from ./arch/powerpc/include/generated/asm/preempt.h:1, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:51, from fs/fs-writeback.c:19: In function 'strncpy', inlined from 'perf_trace_writeback_page_template' at ./include/trace/events/writeback.h:56:1: ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix it by using the new strscpy_pad() which was introduced in "lib/string: Add strscpy_pad() function" and will always be NUL-terminated instead of strncpy(). Also, change strlcpy() to use strscpy_pad() in this file for consistency. Link: http://lkml.kernel.org/r/1564075099-27750-1-git-send-email-cai@lca.pw Fixes:455b286468
("writeback: Initial tracing support") Fixes:028c2dd184
("writeback: Add tracing to balance_dirty_pages") Fixes:e84d0a4f8e
("writeback: trace event writeback_queue_io") Fixes:b48c104d22
("writeback: trace event bdi_dirty_ratelimit") Fixes:cc1676d917
("writeback: Move requeueing when I_SYNC set to writeback_sb_inodes()") Fixes:9fb0a7da0c
("writeback: add more tracepoints") Signed-off-by: Qian Cai <cai@lca.pw> Reviewed-by: Jan Kara <jack@suse.cz> Cc: Tobin C. Harding <tobin@kernel.org> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Tejun Heo <tj@kernel.org> Cc: Dave Chinner <dchinner@redhat.com> Cc: Fengguang Wu <fengguang.wu@intel.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Joe Perches <joe@perches.com> Cc: Kees Cook <keescook@chromium.org> Cc: Jann Horn <jannh@google.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Nitin Gote <nitin.r.gote@intel.com> Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Cc: Stephen Kitt <steve@sk2.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
917cda2790
commit
d1a445d3b8
@ -66,8 +66,9 @@ DECLARE_EVENT_CLASS(writeback_page_template,
|
|||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
strncpy(__entry->name,
|
strscpy_pad(__entry->name,
|
||||||
mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32);
|
mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)",
|
||||||
|
32);
|
||||||
__entry->ino = mapping ? mapping->host->i_ino : 0;
|
__entry->ino = mapping ? mapping->host->i_ino : 0;
|
||||||
__entry->index = page->index;
|
__entry->index = page->index;
|
||||||
),
|
),
|
||||||
@ -110,8 +111,8 @@ DECLARE_EVENT_CLASS(writeback_dirty_inode_template,
|
|||||||
struct backing_dev_info *bdi = inode_to_bdi(inode);
|
struct backing_dev_info *bdi = inode_to_bdi(inode);
|
||||||
|
|
||||||
/* may be called for files on pseudo FSes w/ unregistered bdi */
|
/* may be called for files on pseudo FSes w/ unregistered bdi */
|
||||||
strncpy(__entry->name,
|
strscpy_pad(__entry->name,
|
||||||
bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32);
|
bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32);
|
||||||
__entry->ino = inode->i_ino;
|
__entry->ino = inode->i_ino;
|
||||||
__entry->state = inode->i_state;
|
__entry->state = inode->i_state;
|
||||||
__entry->flags = flags;
|
__entry->flags = flags;
|
||||||
@ -316,8 +317,8 @@ DECLARE_EVENT_CLASS(writeback_write_inode_template,
|
|||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
strncpy(__entry->name,
|
strscpy_pad(__entry->name,
|
||||||
dev_name(inode_to_bdi(inode)->dev), 32);
|
dev_name(inode_to_bdi(inode)->dev), 32);
|
||||||
__entry->ino = inode->i_ino;
|
__entry->ino = inode->i_ino;
|
||||||
__entry->sync_mode = wbc->sync_mode;
|
__entry->sync_mode = wbc->sync_mode;
|
||||||
__entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc);
|
__entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc);
|
||||||
@ -360,8 +361,9 @@ DECLARE_EVENT_CLASS(writeback_work_class,
|
|||||||
__field(unsigned int, cgroup_ino)
|
__field(unsigned int, cgroup_ino)
|
||||||
),
|
),
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
strncpy(__entry->name,
|
strscpy_pad(__entry->name,
|
||||||
wb->bdi->dev ? dev_name(wb->bdi->dev) : "(unknown)", 32);
|
wb->bdi->dev ? dev_name(wb->bdi->dev) :
|
||||||
|
"(unknown)", 32);
|
||||||
__entry->nr_pages = work->nr_pages;
|
__entry->nr_pages = work->nr_pages;
|
||||||
__entry->sb_dev = work->sb ? work->sb->s_dev : 0;
|
__entry->sb_dev = work->sb ? work->sb->s_dev : 0;
|
||||||
__entry->sync_mode = work->sync_mode;
|
__entry->sync_mode = work->sync_mode;
|
||||||
@ -414,7 +416,7 @@ DECLARE_EVENT_CLASS(writeback_class,
|
|||||||
__field(unsigned int, cgroup_ino)
|
__field(unsigned int, cgroup_ino)
|
||||||
),
|
),
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
|
strscpy_pad(__entry->name, dev_name(wb->bdi->dev), 32);
|
||||||
__entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
|
__entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
|
||||||
),
|
),
|
||||||
TP_printk("bdi %s: cgroup_ino=%u",
|
TP_printk("bdi %s: cgroup_ino=%u",
|
||||||
@ -436,7 +438,7 @@ TRACE_EVENT(writeback_bdi_register,
|
|||||||
__array(char, name, 32)
|
__array(char, name, 32)
|
||||||
),
|
),
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
strncpy(__entry->name, dev_name(bdi->dev), 32);
|
strscpy_pad(__entry->name, dev_name(bdi->dev), 32);
|
||||||
),
|
),
|
||||||
TP_printk("bdi %s",
|
TP_printk("bdi %s",
|
||||||
__entry->name
|
__entry->name
|
||||||
@ -461,7 +463,7 @@ DECLARE_EVENT_CLASS(wbc_class,
|
|||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
strncpy(__entry->name, dev_name(bdi->dev), 32);
|
strscpy_pad(__entry->name, dev_name(bdi->dev), 32);
|
||||||
__entry->nr_to_write = wbc->nr_to_write;
|
__entry->nr_to_write = wbc->nr_to_write;
|
||||||
__entry->pages_skipped = wbc->pages_skipped;
|
__entry->pages_skipped = wbc->pages_skipped;
|
||||||
__entry->sync_mode = wbc->sync_mode;
|
__entry->sync_mode = wbc->sync_mode;
|
||||||
@ -512,7 +514,7 @@ TRACE_EVENT(writeback_queue_io,
|
|||||||
),
|
),
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
unsigned long *older_than_this = work->older_than_this;
|
unsigned long *older_than_this = work->older_than_this;
|
||||||
strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
|
strscpy_pad(__entry->name, dev_name(wb->bdi->dev), 32);
|
||||||
__entry->older = older_than_this ? *older_than_this : 0;
|
__entry->older = older_than_this ? *older_than_this : 0;
|
||||||
__entry->age = older_than_this ?
|
__entry->age = older_than_this ?
|
||||||
(jiffies - *older_than_this) * 1000 / HZ : -1;
|
(jiffies - *older_than_this) * 1000 / HZ : -1;
|
||||||
@ -598,7 +600,7 @@ TRACE_EVENT(bdi_dirty_ratelimit,
|
|||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
strlcpy(__entry->bdi, dev_name(wb->bdi->dev), 32);
|
strscpy_pad(__entry->bdi, dev_name(wb->bdi->dev), 32);
|
||||||
__entry->write_bw = KBps(wb->write_bandwidth);
|
__entry->write_bw = KBps(wb->write_bandwidth);
|
||||||
__entry->avg_write_bw = KBps(wb->avg_write_bandwidth);
|
__entry->avg_write_bw = KBps(wb->avg_write_bandwidth);
|
||||||
__entry->dirty_rate = KBps(dirty_rate);
|
__entry->dirty_rate = KBps(dirty_rate);
|
||||||
@ -663,7 +665,7 @@ TRACE_EVENT(balance_dirty_pages,
|
|||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
unsigned long freerun = (thresh + bg_thresh) / 2;
|
unsigned long freerun = (thresh + bg_thresh) / 2;
|
||||||
strlcpy(__entry->bdi, dev_name(wb->bdi->dev), 32);
|
strscpy_pad(__entry->bdi, dev_name(wb->bdi->dev), 32);
|
||||||
|
|
||||||
__entry->limit = global_wb_domain.dirty_limit;
|
__entry->limit = global_wb_domain.dirty_limit;
|
||||||
__entry->setpoint = (global_wb_domain.dirty_limit +
|
__entry->setpoint = (global_wb_domain.dirty_limit +
|
||||||
@ -723,8 +725,8 @@ TRACE_EVENT(writeback_sb_inodes_requeue,
|
|||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
strncpy(__entry->name,
|
strscpy_pad(__entry->name,
|
||||||
dev_name(inode_to_bdi(inode)->dev), 32);
|
dev_name(inode_to_bdi(inode)->dev), 32);
|
||||||
__entry->ino = inode->i_ino;
|
__entry->ino = inode->i_ino;
|
||||||
__entry->state = inode->i_state;
|
__entry->state = inode->i_state;
|
||||||
__entry->dirtied_when = inode->dirtied_when;
|
__entry->dirtied_when = inode->dirtied_when;
|
||||||
@ -797,8 +799,8 @@ DECLARE_EVENT_CLASS(writeback_single_inode_template,
|
|||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
strncpy(__entry->name,
|
strscpy_pad(__entry->name,
|
||||||
dev_name(inode_to_bdi(inode)->dev), 32);
|
dev_name(inode_to_bdi(inode)->dev), 32);
|
||||||
__entry->ino = inode->i_ino;
|
__entry->ino = inode->i_ino;
|
||||||
__entry->state = inode->i_state;
|
__entry->state = inode->i_state;
|
||||||
__entry->dirtied_when = inode->dirtied_when;
|
__entry->dirtied_when = inode->dirtied_when;
|
||||||
|
Loading…
Reference in New Issue
Block a user