Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3988783imm; Tue, 29 May 2018 18:58:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLEbI1e5RuOSd4obFo0H3r/bgxu2hFflYeQzqy5XA0A9FUCiV20fEYcm0EKaOMqtKxpcHCg X-Received: by 2002:a17:902:31a4:: with SMTP id x33-v6mr825734plb.355.1527645487716; Tue, 29 May 2018 18:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527645487; cv=none; d=google.com; s=arc-20160816; b=qRIpaZ/Ch2gbK4bWp7dNKBTVDuGQRiI0HhATjQ2cDlTWnDaRpdNyLylCv4WITdSBOM XG084n34ZIqXIc64VDZdzpGyEzA5IrGLOD6BbTzWRIZSsRyowjYnFPNSzWuhEpUMc6xV gMM6XzHuwyj75IbkX8PaRTRjC18xzPZjaztBMU6XgQeLq9pBi/wXuSD/0MU5KQwTQz+J XBunJwzVsXScB/nBKimQE8KuldVJWJJZyhMyG2zT1/5d65MvUTykNbhHbZIkKPCQb6Cz ia12U8FcbSbapbeqDugK44nVR+x0UdbRSXFQeIBdwfBZm+9Jv9/5K7Obo+0dNmb+SG8J AQ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=5eJ924+ZEQI0+T8SXqg8FogNsUcAcaj3jhaDvxiQWPw=; b=DBfwjrNe0SbIWtgOIvf4R/nK8GDxzbQKjW4STtO/VNAtvoK0SbN2O+9/ILkRsdy7/p ZwznCpFYYXVGDewDM3apotcX6jZ6qwVOyOTpQSzJ6/7OkGY2QWQ9y0gP2YQyYprZJsY6 uZm4Ut4NCWmSswNxg3RCUi3+CkUyH7JKRDW6A/Bpvm19q1os6i5cfgS8ZlBchUvQfvCd P3srrLDp+BDzuGLpZ1/hY8/MXhG8taNKZVMWLUzvCSdmdM3IcxfThM/u5cF0x3TSZvlL ElP+WMHnpw+6p6ad8EmDrJYocgXjpNsFYcqdZ0YCeVJB/TgKWH5DorRLGWZ9lT9FS2T9 k3gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bA/kHPqO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8-v6si11427088pgu.6.2018.05.29.18.57.53; Tue, 29 May 2018 18:58:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bA/kHPqO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968607AbeE3B4r (ORCPT + 99 others); Tue, 29 May 2018 21:56:47 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34140 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968467AbeE3B4q (ORCPT ); Tue, 29 May 2018 21:56:46 -0400 Received: by mail-oi0-f67.google.com with SMTP id i205-v6so357549oib.1 for ; Tue, 29 May 2018 18:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5eJ924+ZEQI0+T8SXqg8FogNsUcAcaj3jhaDvxiQWPw=; b=bA/kHPqOkemF+nudqOYV9ZWfjZtVJBQAt97MohdYzJe36nhDc9lkKDf9RAZrn1DhjI Ln87h5ZHdpJ9dRD5oduPovWbZaHoMuf1PBtxVT3oF62H8yunnlOJMZBhPxuxh1msSwuE r9s0X1XiaJhyCZAZY7dgskY2xKsCdN2vXl7x9NbGDKbQj6h0Fis2fc0IGSvS0Km8kxEV 9XeoVaVZVmcLnp6Zj4zmQuTE4nWiiElzZGge2qMg3KoelzLH55ROU1CMNMyEc/AJ3RYn zRNldrEAmewY5fShjLosio02gRJVpOTFnyFHKEeh6NDskyrnYhrK7+QkJ4WnaIwbVUgo mUIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5eJ924+ZEQI0+T8SXqg8FogNsUcAcaj3jhaDvxiQWPw=; b=IXGfQgBHBF+eIcs6P0lQbKMalUJIJPUQvBuT9cEhY80szv4m/vBSeiI2RKD8Ad4Rox 5dd6kGhFSUmxfSa5djuJNhsGVGGPw2yw7Z8ZZDy65WeEaKgvi+93QGxDZ746JSLNyUkJ cofG/sxkQEC1lTzGszXk3QXLIoFAAFOxmvLkaAXbYL1RrdVjRRouin18L6Q3gPmQ9pkz rwZnNCF2SBbW22O1B5pz5lRc68Bvv2GFfKNxXQ67wmdHhGYuYCx4rBMXg3voheF2uDka wotB1IAVhZlBpRRrtt3P7Vfm6sgMKrlB1FQOzjegKuQ510dZDd2clY+g8kav/rtQb/Wi XOJw== X-Gm-Message-State: ALKqPwe7JUz6iXqOaiAEwxj0y/PS/9OElVlb9lelHLGErwqcIBSnp3hF BH7TS0uDAQaPKujT9r9xLe0WWLV5DZ+w26p1rnA= X-Received: by 2002:aca:55c6:: with SMTP id j189-v6mr415229oib.53.1527645405247; Tue, 29 May 2018 18:56:45 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2451:0:0:0:0:0 with HTTP; Tue, 29 May 2018 18:56:44 -0700 (PDT) In-Reply-To: <1527575868-4156-1-git-send-email-nick.desaulniers@gmail.com> References: <1527575868-4156-1-git-send-email-nick.desaulniers@gmail.com> From: Nick Desaulniers Date: Tue, 29 May 2018 18:56:44 -0700 Message-ID: Subject: Re: [PATCH] writeback: tracing: prefer strlcpy to strncpy To: "Steven Rostedt (VMware)" , Ingo Molnar Cc: Nick Desaulniers , Greg Kroah-Hartman , Jens Axboe , Thomas Gleixner , Philippe Ombredanne , Shaohua Li , Linux Kernel Mailing List , ebiggers@google.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 28, 2018 at 11:37 PM, Nick Desaulniers wrote: > Fixes a stringop-truncation warning from gcc-8. > > Signed-off-by: Nick Desaulniers > --- > include/trace/events/writeback.h | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h > index 32db72c..cfaf57d 100644 > --- a/include/trace/events/writeback.h > +++ b/include/trace/events/writeback.h > @@ -66,7 +66,7 @@ TRACE_EVENT(writeback_dirty_page, > ), > > TP_fast_assign( > - strncpy(__entry->name, > + strlcpy(__entry->name, > mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32); > __entry->ino = mapping ? mapping->host->i_ino : 0; > __entry->index = page->index; > @@ -96,7 +96,7 @@ DECLARE_EVENT_CLASS(writeback_dirty_inode_template, > struct backing_dev_info *bdi = inode_to_bdi(inode); > > /* may be called for files on pseudo FSes w/ unregistered bdi */ > - strncpy(__entry->name, > + strlcpy(__entry->name, > bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32); > __entry->ino = inode->i_ino; > __entry->state = inode->i_state; > @@ -176,7 +176,7 @@ DECLARE_EVENT_CLASS(writeback_write_inode_template, > ), > > TP_fast_assign( > - strncpy(__entry->name, > + strlcpy(__entry->name, > dev_name(inode_to_bdi(inode)->dev), 32); > __entry->ino = inode->i_ino; > __entry->sync_mode = wbc->sync_mode; > @@ -220,7 +220,7 @@ DECLARE_EVENT_CLASS(writeback_work_class, > __field(unsigned int, cgroup_ino) > ), > TP_fast_assign( > - strncpy(__entry->name, > + strlcpy(__entry->name, > wb->bdi->dev ? dev_name(wb->bdi->dev) : "(unknown)", 32); > __entry->nr_pages = work->nr_pages; > __entry->sb_dev = work->sb ? work->sb->s_dev : 0; > @@ -274,7 +274,7 @@ DECLARE_EVENT_CLASS(writeback_class, > __field(unsigned int, cgroup_ino) > ), > TP_fast_assign( > - strncpy(__entry->name, dev_name(wb->bdi->dev), 32); > + strlcpy(__entry->name, dev_name(wb->bdi->dev), 32); > __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); > ), > TP_printk("bdi %s: cgroup_ino=%u", > @@ -296,7 +296,7 @@ TRACE_EVENT(writeback_bdi_register, > __array(char, name, 32) > ), > TP_fast_assign( > - strncpy(__entry->name, dev_name(bdi->dev), 32); > + strlcpy(__entry->name, dev_name(bdi->dev), 32); > ), > TP_printk("bdi %s", > __entry->name > @@ -321,7 +321,7 @@ DECLARE_EVENT_CLASS(wbc_class, > ), > > TP_fast_assign( > - strncpy(__entry->name, dev_name(bdi->dev), 32); > + strlcpy(__entry->name, dev_name(bdi->dev), 32); > __entry->nr_to_write = wbc->nr_to_write; > __entry->pages_skipped = wbc->pages_skipped; > __entry->sync_mode = wbc->sync_mode; > @@ -372,7 +372,7 @@ TRACE_EVENT(writeback_queue_io, > ), > TP_fast_assign( > unsigned long *older_than_this = work->older_than_this; > - strncpy(__entry->name, dev_name(wb->bdi->dev), 32); > + strlcpy(__entry->name, dev_name(wb->bdi->dev), 32); > __entry->older = older_than_this ? *older_than_this : 0; > __entry->age = older_than_this ? > (jiffies - *older_than_this) * 1000 / HZ : -1; > @@ -583,7 +583,7 @@ TRACE_EVENT(writeback_sb_inodes_requeue, > ), > > TP_fast_assign( > - strncpy(__entry->name, > + strlcpy(__entry->name, > dev_name(inode_to_bdi(inode)->dev), 32); > __entry->ino = inode->i_ino; > __entry->state = inode->i_state; > @@ -657,7 +657,7 @@ DECLARE_EVENT_CLASS(writeback_single_inode_template, > ), > > TP_fast_assign( > - strncpy(__entry->name, > + strlcpy(__entry->name, > dev_name(inode_to_bdi(inode)->dev), 32); > __entry->ino = inode->i_ino; > __entry->state = inode->i_state; > -- > 2.7.4 > Eric points out this wont initialize the rest of the dest if src if less than size.