cpuset: Work around a clang compiler warning
diff mbox series

Message ID 20180626164552.90133-1-astrachan@google.com
State Accepted
Headers show
Series
  • cpuset: Work around a clang compiler warning
Related show

Commit Message

Alistair Strachan June 26, 2018, 4:45 p.m. UTC
The clang compiler will warn about pasting a C string literal and an
int, suggesting that array indexing should be used instead:

testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c:143:3: error:
 adding 'int' to a string does not append to the string
 [-Werror,-Wstring-plus-int]
  while_each_childdir(SYS_CPU_DIR, "/", c_relpath,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
testcases/kernel/controllers/cpuset/cpuset_lib/common.h:54:13: note:
 expanded from macro 'while_each_childdir'
  p_relpath + start); \
  ~~~~~~~~~~^~~~~~~
testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c:143:3: note:
 use array indexing to silence this warning

This seems like a strange warning, but the suggestion has no effect on
code generation or readability, so change it to keep clang happy.

Signed-off-by: Alistair Strachan <astrachan@google.com>
---
 testcases/kernel/controllers/cpuset/cpuset_lib/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Cyril Hrubis June 27, 2018, 4:01 p.m. UTC | #1
Hi!
Pushed, thanks.

Patch
diff mbox series

diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/common.h b/testcases/kernel/controllers/cpuset/cpuset_lib/common.h
index bd347413c..28e948e63 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/common.h
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/common.h
@@ -51,7 +51,7 @@ 
 		start = 1;						\
 									\
 	snprintf(fullpath, sizeof(fullpath), "%s%s", basepath,		\
-		p_relpath + start);					\
+		 &p_relpath[start]);					\
 	pathlen = strlen(fullpath);					\
 									\
 	if ((dp = opendir(fullpath)) == NULL)				\