• Qian Cai's avatar
    include/trace/events/writeback.h: fix -Wstringop-truncation warnings · d1a445d3
    Qian Cai authored
    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: 455b2864 ("writeback: Initial tracing support")
    Fixes: 028c2dd1 ("writeback: Add tracing to balance_dirty_pages")
    Fixes: e84d0a4f ("writeback: trace event writeback_queue_io")
    Fixes: b48c104d ("writeback: trace event bdi_dirty_ratelimit")
    Fixes: cc1676d9 ("writeback: Move requeueing when I_SYNC set to writeback_sb_inodes()")
    Fixes: 9fb0a7da ("writeback: add more tracepoints")
    Signed-off-by: default avatarQian Cai <cai@lca.pw>
    Reviewed-by: default avatarJan 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: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    d1a445d3
writeback.h 23.3 KB