diff mbox series

[v1,2/2] libtracefs: Fix compiler -Wmemsize-comparison warning

Message ID 20221215183151.2685460-2-irogers@google.com (mailing list archive)
State Accepted
Commit b71d3e3654e242ec4d98d1df7e5169943939c615
Headers show
Series [v1,1/2] libtracefs: Move initialization below a null test. | expand

Commit Message

Ian Rogers Dec. 15, 2022, 6:31 p.m. UTC
Fixes the following clang warning:

utest/tracefs-utest.c:828:75: error: size argument in 'strncmp' call is a comparison [-Werror,-Wmemsize-comparison]
            (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0)))
                                                              ~~~~~~~~~~~~~~~~~~~^~~~
utest/tracefs-utest.c:828:22: note: did you mean to compare the result of 'strncmp' instead?
            (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0)))
                            ^                                                        ~
                                                                                )
utest/tracefs-utest.c:828:56: note: explicitly cast the argument to size_t to silence this warning
            (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0)))
                                                              ^
                                                              (size_t)(              )

Signed-off-by: Ian Rogers <irogers@google.com>
---
 utest/tracefs-utest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Rostedt Dec. 15, 2022, 7:03 p.m. UTC | #1
On Thu, 15 Dec 2022 10:31:51 -0800
Ian Rogers <irogers@google.com> wrote:

> Fixes the following clang warning:
> 
> utest/tracefs-utest.c:828:75: error: size argument in 'strncmp' call is a comparison [-Werror,-Wmemsize-comparison]
>             (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0)))
>                                                               ~~~~~~~~~~~~~~~~~~~^~~~
> utest/tracefs-utest.c:828:22: note: did you mean to compare the result of 'strncmp' instead?
>             (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0)))
>                             ^                                                        ~
>                                                                                 )
> utest/tracefs-utest.c:828:56: note: explicitly cast the argument to size_t to silence this warning
>             (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0)))
>                                                               ^
>                                                               (size_t)(              )

This is why I hate lisp!

Thanks, I'll apply this.

-- Steve
diff mbox series

Patch

diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 629cf2b..e0e3c07 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -825,7 +825,7 @@  static void test_mounting(void)
 		mount("debugfs", save_debug, "debugfs", 0, NULL);
 
 	if (save_tracing &&
-	    (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0)))
+	    (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug)) != 0))
 		mount("tracefs", save_tracing, "tracefs", 0, NULL);
 
 	free(save_debug);