linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] selftest/bpf: remove warns for enable_all_controllers
@ 2019-10-02 12:04 Ivan Khoronzhuk
  2019-10-02 12:04 ` [PATCH bpf-next 1/2] selftests/bpf: add static to enable_all_controllers() Ivan Khoronzhuk
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ivan Khoronzhuk @ 2019-10-02 12:04 UTC (permalink / raw)
  To: shuah, ast, daniel
  Cc: kafai, songliubraving, yhs, linux-kselftest, netdev, bpf,
	linux-kernel, Ivan Khoronzhuk

This micro series fixes annoying warn described in patches
while samples/bpf build. Second patch fixes new warn that
comes after fixing warn of first patch, that was masked.

Ivan Khoronzhuk (2):
  selftests/bpf: add static to enable_all_controllers()
  selftests/bpf: correct path to include msg + path

 tools/testing/selftests/bpf/cgroup_helpers.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH bpf-next 1/2] selftests/bpf: add static to enable_all_controllers()
  2019-10-02 12:04 [PATCH bpf-next 0/2] selftest/bpf: remove warns for enable_all_controllers Ivan Khoronzhuk
@ 2019-10-02 12:04 ` Ivan Khoronzhuk
  2019-10-02 16:26   ` Song Liu
  2019-10-02 12:04 ` [PATCH bpf-next 2/2] selftests/bpf: correct path to include msg + path Ivan Khoronzhuk
  2019-10-03 15:39 ` [PATCH bpf-next 0/2] selftest/bpf: remove warns for enable_all_controllers Daniel Borkmann
  2 siblings, 1 reply; 6+ messages in thread
From: Ivan Khoronzhuk @ 2019-10-02 12:04 UTC (permalink / raw)
  To: shuah, ast, daniel
  Cc: kafai, songliubraving, yhs, linux-kselftest, netdev, bpf,
	linux-kernel, Ivan Khoronzhuk

Add static to enable_all_controllers() to get rid from annoying warn:

samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:44:5:
warning: no previous prototype for ‘enable_all_controllers’
[-Wmissing-prototypes]
 int enable_all_controllers(char *cgroup_path)

while samples/bpf build.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 tools/testing/selftests/bpf/cgroup_helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c
index e95c33e333a4..4d74f3c4619b 100644
--- a/tools/testing/selftests/bpf/cgroup_helpers.c
+++ b/tools/testing/selftests/bpf/cgroup_helpers.c
@@ -41,7 +41,7 @@
  *
  * If successful, 0 is returned.
  */
-int enable_all_controllers(char *cgroup_path)
+static int enable_all_controllers(char *cgroup_path)
 {
 	char path[PATH_MAX + 1];
 	char buf[PATH_MAX];
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH bpf-next 2/2] selftests/bpf: correct path to include msg + path
  2019-10-02 12:04 [PATCH bpf-next 0/2] selftest/bpf: remove warns for enable_all_controllers Ivan Khoronzhuk
  2019-10-02 12:04 ` [PATCH bpf-next 1/2] selftests/bpf: add static to enable_all_controllers() Ivan Khoronzhuk
@ 2019-10-02 12:04 ` Ivan Khoronzhuk
  2019-10-02 16:28   ` Song Liu
  2019-10-03 15:39 ` [PATCH bpf-next 0/2] selftest/bpf: remove warns for enable_all_controllers Daniel Borkmann
  2 siblings, 1 reply; 6+ messages in thread
From: Ivan Khoronzhuk @ 2019-10-02 12:04 UTC (permalink / raw)
  To: shuah, ast, daniel
  Cc: kafai, songliubraving, yhs, linux-kselftest, netdev, bpf,
	linux-kernel, Ivan Khoronzhuk

The "path" buf is supposed to contain path + printf msg up to 24 bytes.
It will be cut anyway, but compiler generates truncation warns like:

"
samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c: In
function ‘setup_cgroup_environment’:
samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:52:34:
warning: ‘/cgroup.controllers’ directive output may be truncated
writing 19 bytes into a region of size between 1 and 4097
[-Wformat-truncation=]
snprintf(path, sizeof(path), "%s/cgroup.controllers", cgroup_path);
				  ^~~~~~~~~~~~~~~~~~~
samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:52:2:
note: ‘snprintf’ output between 20 and 4116 bytes into a destination
of size 4097
snprintf(path, sizeof(path), "%s/cgroup.controllers", cgroup_path);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:72:34:
warning: ‘/cgroup.subtree_control’ directive output may be truncated
writing 23 bytes into a region of size between 1 and 4097
[-Wformat-truncation=]
snprintf(path, sizeof(path), "%s/cgroup.subtree_control",
				  ^~~~~~~~~~~~~~~~~~~~~~~
cgroup_path);
samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:72:2:
note: ‘snprintf’ output between 24 and 4120 bytes into a destination
of size 4097
snprintf(path, sizeof(path), "%s/cgroup.subtree_control",
cgroup_path);
"

In order to avoid warns, lets decrease buf size for cgroup workdir on
24 bytes with assumption to include also "/cgroup.subtree_control" to
the address. The cut will never happen anyway.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 tools/testing/selftests/bpf/cgroup_helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c
index 4d74f3c4619b..0fb910df5387 100644
--- a/tools/testing/selftests/bpf/cgroup_helpers.c
+++ b/tools/testing/selftests/bpf/cgroup_helpers.c
@@ -98,7 +98,7 @@ static int enable_all_controllers(char *cgroup_path)
  */
 int setup_cgroup_environment(void)
 {
-	char cgroup_workdir[PATH_MAX + 1];
+	char cgroup_workdir[PATH_MAX - 24];
 
 	format_cgroup_path(cgroup_workdir, "");
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next 1/2] selftests/bpf: add static to enable_all_controllers()
  2019-10-02 12:04 ` [PATCH bpf-next 1/2] selftests/bpf: add static to enable_all_controllers() Ivan Khoronzhuk
@ 2019-10-02 16:26   ` Song Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Song Liu @ 2019-10-02 16:26 UTC (permalink / raw)
  To: Ivan Khoronzhuk
  Cc: Shuah Khan, Alexei Starovoitov, Daniel Borkmann, Martin Lau,
	Yonghong Song, linux-kselftest, netdev, bpf, linux-kernel



> On Oct 2, 2019, at 5:04 AM, Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> wrote:
> 
> Add static to enable_all_controllers() to get rid from annoying warn:
> 
> samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:44:5:
> warning: no previous prototype for ‘enable_all_controllers’
> [-Wmissing-prototypes]
> int enable_all_controllers(char *cgroup_path)
> 
> while samples/bpf build.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

Acked-by: Song Liu <songliubraving@fb.com> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next 2/2] selftests/bpf: correct path to include msg + path
  2019-10-02 12:04 ` [PATCH bpf-next 2/2] selftests/bpf: correct path to include msg + path Ivan Khoronzhuk
@ 2019-10-02 16:28   ` Song Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Song Liu @ 2019-10-02 16:28 UTC (permalink / raw)
  To: Ivan Khoronzhuk
  Cc: shuah, ast, daniel, Martin Lau, Yonghong Song, linux-kselftest,
	netdev, bpf, linux-kernel



> On Oct 2, 2019, at 5:04 AM, Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> wrote:
> 
> The "path" buf is supposed to contain path + printf msg up to 24 bytes.
> It will be cut anyway, but compiler generates truncation warns like:
> 
> "
> samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c: In
> function ‘setup_cgroup_environment’:
> samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:52:34:
> warning: ‘/cgroup.controllers’ directive output may be truncated
> writing 19 bytes into a region of size between 1 and 4097
> [-Wformat-truncation=]
> snprintf(path, sizeof(path), "%s/cgroup.controllers", cgroup_path);
> 				  ^~~~~~~~~~~~~~~~~~~
> samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:52:2:
> note: ‘snprintf’ output between 20 and 4116 bytes into a destination
> of size 4097
> snprintf(path, sizeof(path), "%s/cgroup.controllers", cgroup_path);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:72:34:
> warning: ‘/cgroup.subtree_control’ directive output may be truncated
> writing 23 bytes into a region of size between 1 and 4097
> [-Wformat-truncation=]
> snprintf(path, sizeof(path), "%s/cgroup.subtree_control",
> 				  ^~~~~~~~~~~~~~~~~~~~~~~
> cgroup_path);
> samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:72:2:
> note: ‘snprintf’ output between 24 and 4120 bytes into a destination
> of size 4097
> snprintf(path, sizeof(path), "%s/cgroup.subtree_control",
> cgroup_path);
> "
> 
> In order to avoid warns, lets decrease buf size for cgroup workdir on
> 24 bytes with assumption to include also "/cgroup.subtree_control" to
> the address. The cut will never happen anyway.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>


Acked-by: Song Liu <songliubraving@fb.com> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next 0/2] selftest/bpf: remove warns for enable_all_controllers
  2019-10-02 12:04 [PATCH bpf-next 0/2] selftest/bpf: remove warns for enable_all_controllers Ivan Khoronzhuk
  2019-10-02 12:04 ` [PATCH bpf-next 1/2] selftests/bpf: add static to enable_all_controllers() Ivan Khoronzhuk
  2019-10-02 12:04 ` [PATCH bpf-next 2/2] selftests/bpf: correct path to include msg + path Ivan Khoronzhuk
@ 2019-10-03 15:39 ` Daniel Borkmann
  2 siblings, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2019-10-03 15:39 UTC (permalink / raw)
  To: Ivan Khoronzhuk
  Cc: shuah, ast, kafai, songliubraving, yhs, linux-kselftest, netdev,
	bpf, linux-kernel

On Wed, Oct 02, 2019 at 03:04:02PM +0300, Ivan Khoronzhuk wrote:
> This micro series fixes annoying warn described in patches
> while samples/bpf build. Second patch fixes new warn that
> comes after fixing warn of first patch, that was masked.
> 
> Ivan Khoronzhuk (2):
>   selftests/bpf: add static to enable_all_controllers()
>   selftests/bpf: correct path to include msg + path
> 
>  tools/testing/selftests/bpf/cgroup_helpers.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-03 15:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 12:04 [PATCH bpf-next 0/2] selftest/bpf: remove warns for enable_all_controllers Ivan Khoronzhuk
2019-10-02 12:04 ` [PATCH bpf-next 1/2] selftests/bpf: add static to enable_all_controllers() Ivan Khoronzhuk
2019-10-02 16:26   ` Song Liu
2019-10-02 12:04 ` [PATCH bpf-next 2/2] selftests/bpf: correct path to include msg + path Ivan Khoronzhuk
2019-10-02 16:28   ` Song Liu
2019-10-03 15:39 ` [PATCH bpf-next 0/2] selftest/bpf: remove warns for enable_all_controllers Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).