All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Tejun Heo <tj@kernel.org>,
	Linux-Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
Subject: Re: linux-next: build warning after merge of the cgroup tree
Date: Fri, 15 Dec 2017 10:58:04 +0100	[thread overview]
Message-ID: <CAK8P3a1v59UJ1XhgGELZbFNDyv0SNm2hM2Tghnq4+4Own57CBA@mail.gmail.com> (raw)
In-Reply-To: <20171213145627.656e3909@canb.auug.org.au>

On Wed, Dec 13, 2017 at 4:56 AM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> Hi Tejun,
>
> After merging the cgroup tree, today's linux-next build (arm
> multi_v7_defconfig) produced this warning:
>
> kernel/cgroup/cgroup.c: In function 'init_cgroup_root':
> kernel/cgroup/cgroup.c:1867:3: warning: ignoring return value of 'strscpy', declared with attribute warn_unused_result [-Wunused-result]
>    strscpy(root->release_agent_path, opts->release_agent, PATH_MAX);
>    ^
> kernel/cgroup/cgroup.c:1869:3: warning: ignoring return value of 'strscpy', declared with attribute warn_unused_result [-Wunused-result]
>    strscpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN);
>    ^
> kernel/cgroup/cgroup.c: In function 'cgroup_file_name':
> kernel/cgroup/cgroup.c:1400:3: warning: ignoring return value of 'strscpy', declared with attribute warn_unused_result [-Wunused-result]
>    strscpy(buf, cft->name, CGROUP_FILE_NAME_MAX);
>    ^
>
> Introduced by commit
>
>   e7fd37ba1217 ("cgroup: avoid copying strings longer than the buffers")

As long as cft->name is guaranteed to be NUL-terminated, using strlcpy() would
work just as well and avoid that warning, so the change below could be folded
into that commit.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index dc442a5d88b9..3cced1259cd3 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1397,7 +1397,7 @@ static char *cgroup_file_name(struct cgroup
*cgrp, const struct cftype *cft,
                         cgroup_on_dfl(cgrp) ? ss->name : ss->legacy_name,
                         cft->name);
        else
-               strscpy(buf, cft->name, CGROUP_FILE_NAME_MAX);
+               strlcpy(buf, cft->name, CGROUP_FILE_NAME_MAX);
        return buf;
 }

@@ -1874,9 +1874,9 @@ void init_cgroup_root(struct cgroup_root *root,
struct cgroup_sb_opts *opts)

        root->flags = opts->flags;
        if (opts->release_agent)
-               strscpy(root->release_agent_path, opts->release_agent,
PATH_MAX);
+               strlcpy(root->release_agent_path, opts->release_agent,
PATH_MAX);
        if (opts->name)
-               strscpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN);
+               strlcpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN);
        if (opts->cpuset_clone_children)
                set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags);
 }

  reply	other threads:[~2017-12-15  9:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13  3:56 linux-next: build warning after merge of the cgroup tree Stephen Rothwell
2017-12-15  9:58 ` Arnd Bergmann [this message]
2017-12-15 13:10   ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2023-07-11  1:15 Stephen Rothwell
2023-07-11  1:22 ` Tejun Heo
2023-07-11  2:06   ` Miaohe Lin
2017-05-01  4:53 Stephen Rothwell
2013-08-27 10:17 Stephen Rothwell
2013-08-27 18:33 ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK8P3a1v59UJ1XhgGELZbFNDyv0SNm2hM2Tghnq4+4Own57CBA@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mashimiao.fnst@cn.fujitsu.com \
    --cc=sfr@canb.auug.org.au \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.