Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings in nc_perf code tst_create_files.c and bm_file.c #1770

Closed
edwardhartnett opened this issue Jun 30, 2020 · 0 comments · Fixed by #1785
Closed

Warnings in nc_perf code tst_create_files.c and bm_file.c #1770

edwardhartnett opened this issue Jun 30, 2020 · 0 comments · Fixed by #1785

Comments

@edwardhartnett
Copy link
Contributor

I'm seeing some of these new warnings in nc_perf directory, where I am adding a test. I will fix and submit as part of my next PR.

tst_create_files.c: In function ‘main’:
tst_create_files.c:285:31: warning: ‘%s’ directive writing up to 256 bytes into a region of size 253 [-Wformat-overflow=]
  285 |       sprintf(file_name, "tst_%s2_%dD.nc", type_name[t], ndims);
      |                               ^~
tst_create_files.c:285:7: note: ‘sprintf’ output between 12 and 278 bytes into a destination of size 257
  285 |       sprintf(file_name, "tst_%s2_%dD.nc", type_name[t], ndims);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tst_create_files.c:173:31: warning: ‘%s’ directive writing up to 256 bytes into a region of size 253 [-Wformat-overflow=]
  173 |       sprintf(file_name, "tst_%s2_%dD.nc", type_name[t], ndims);
      |                               ^~
tst_create_files.c:173:7: note: ‘sprintf’ output between 12 and 278 bytes into a destination of size 257
  173 |       sprintf(file_name, "tst_%s2_%dD.nc", type_name[t], ndims);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/bin/bash ../libtool  --tag=CC   --mode=link mpicc  -g -Wall ../liblib/libnetcdf.la -L/usr/local/hdf5-1.10.6_szip_mpich/lib -o tst_create_files tst_create_files.o ../liblib/libnetcdf.la -lhdf5_hl -lhdf5 -lm -ldl -lz -lcurl 
libtool: link: mpicc -g -Wall -o tst_create_files tst_create_files.o   -L/usr/local/hdf5-1.10.6_szip_mpich/lib -L/usr/local/szip-2.1.1/lib ../liblib/.libs/libnetcdf.a /usr/local/hdf5-1.10.6_szip_mpich/lib/libhdf5_hl.so /usr/local/hdf5-1.10.6_szip_mpich/lib/libhdf5.so /usr/local/szip-2.1.1/lib/libsz.so -lm -ldl -lz /usr/lib/x86_64-linux-gnu/libcurl.so -pthread -Wl,-rpath -Wl,/usr/local/hdf5-1.10.6_szip_mpich/lib -Wl,-rpath -Wl,/usr/local/szip-2.1.1/lib -Wl,-rpath -Wl,/usr/local/hdf5-1.10.6_szip_mpich/lib -Wl,-rpath -Wl,/usr/local/szip-2.1.1/lib
depbase=`echo bm_file.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
mpicc -DHAVE_CONFIG_H -I. -I..  -I../include -I../oc2 -I/usr/local/hdf5-1.10.6_szip_mpich/include  -g -Wall -MT bm_file.o -MD -MP -MF $depbase.Tpo -c -o bm_file.o bm_file.c &&\
mv -f $depbase.Tpo $depbase.Po
bm_file.c: In function ‘main’:
bm_file.c:1078:39: warning: ‘%s’ directive writing up to 256 bytes into a region of size 248 [-Wformat-overflow=]
 1078 |         sprintf(file_out_2, "tst_copy_%s", file_out);
      |                                       ^~   ~~~~~~~~
bm_file.c:1078:9: note: ‘sprintf’ output between 10 and 266 bytes into a destination of size 257
 1078 |         sprintf(file_out_2, "tst_copy_%s", file_out);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bm_file.c:1079:33: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
 1079 |         sprintf(cmd, "cp %s %s\n", file_out, file_out_2);
      |                                 ^
bm_file.c:1079:9: note: ‘sprintf’ output between 6 and 518 bytes into a destination of size 517
 1079 |         sprintf(cmd, "cp %s %s\n", file_out, file_out_2);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
depbase=`echo tst_utils.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant