On 05/02/2024 19:21, Arnaldo Carvalho de Melo wrote: > To address this compiler warning: > > /home/acme/git/pahole/pahole.c: In function ‘parse_btf_features’: > /home/acme/git/pahole/pahole.c:1353:9: warning: ‘strncpy’ specified bound 1024 equals destination size [-Wstringop-truncation] > 1353 | strncpy(f, features, sizeof(f)); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > $ gcc -v |& tail -1 > gcc version 13.2.1 20231205 (Red Hat 13.2.1-6) (GCC) > $ > > When building in Release mode, for instance by using the buildcmd.sh > script. > > Cc: Alan Maguire <alan.maguire@xxxxxxxxxx> > Cc: Eduard Zingerman <eddyz87@xxxxxxxxx> > Fixes: 7bc9b9975545ab53 ("pahole: Add --btf_features support") > Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> > Thanks for fixing this Arnaldo! I'll make sure to build in release mode in future. Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx> --- > pahole.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/pahole.c b/pahole.c > index 768a2feb338a2f3c..0e079ae19f231a5a 100644 > --- a/pahole.c > +++ b/pahole.c > @@ -1338,7 +1338,7 @@ static void show_supported_btf_features(FILE *output) > static void parse_btf_features(const char *features, bool strict) > { > char *saveptr = NULL, *s, *feature_name; > - char f[BTF_MAX_FEATURE_STR]; > + char f[BTF_MAX_FEATURE_STR + 1]; > > init_btf_features(); > > @@ -1350,7 +1350,7 @@ static void parse_btf_features(const char *features, bool strict) > return; > } > > - strncpy(f, features, sizeof(f)); > + strncpy(f, features, BTF_MAX_FEATURE_STR)[BTF_MAX_FEATURE_STR] = '\0'; > s = f; > while ((feature_name = strtok_r(s, ",", &saveptr)) != NULL) { > struct btf_feature *feature = find_btf_feature(feature_name);