Skip to contentSkip to conversation

cpuset: Work around a clang compiler warning

PATCH New Alistair Strachan 2 participants 2 messages Jun 26, 2018 – Jun 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpuset: Work around a clang compiler warning

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.

---
 testcases/kernel/controllers/cpuset/cpuset_lib/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/controllers/cpuset/cpuset_lib/common.h +1 -1
index bd347413c..28e948e63 100644
@@ -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)				\