Fix the following strncpy() string truncation warning:
In function ‘strncpy’,
inlined from ‘parse_cgroup_spec’ at ../tools/tools-common.c:92:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
} while (temp && j<CG_CONTROLLER_MAX-1);
/* Store path to the cgroup */
- strncpy(cdptr[i]->path, pathptr, FILENAME_MAX);
- cdptr[i]->path[FILENAME_MAX-1] = '\0';
+ strncpy(cdptr[i]->path, pathptr, FILENAME_MAX - 1);
+ cdptr[i]->path[sizeof(cdptr[i]->path) - 1] = '\0';
return 0;
}