Skip to content

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

@edwardhartnett

Description

@edwardhartnett

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$||'`;\

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions