Skip to content

Fix warnings in unit test BSP #124

Closed
@pcolberg

Description

@pcolberg

Warnings from Ubuntu 22.04 debug build with GCC 11.2:

  • test/fake_bsp/fakegoodbsp.cpp

    [53/113] /usr/bin/g++ -DCL_TARGET_OPENCL_VERSION=300 -DNOMINMAX -DUT_MALLOC_MACROS_DISABLED -DUT_NEW_MACROS_DISABLED -DUT_NEW_OVERRIDES_DISABLED -Dfakegoodbsp_EXPORTS -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/src -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/include -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/include -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/. -g -fPIC -Wall -Wconversion -Wformat -Wformat-security -fno-strict-aliasing -fstack-protector -D_FORTIFY_SOURCE=2 -Og -std=gnu++17 -MD -MT test/fake_bsp/CMakeFiles/fakegoodbsp.dir/fakegoodbsp.cpp.o -MF test/fake_bsp/CMakeFiles/fakegoodbsp.dir/fakegoodbsp.cpp.o.d -o test/fake_bsp/CMakeFiles/fakegoodbsp.dir/fakegoodbsp.cpp.o -c /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp: In function 'int aocl_mmd_get_info(int, aocl_mmd_info_t, size_t, void*, size_t*)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:47:26: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 16 [-Wstringop-overread]
       47 |     size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1;                               \
          |                   ~~~~~~~^~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:140:5: note: in expansion of macro 'RESULT_STR'
      140 |     RESULT_STR(ACL_BOARD_NAME);
          |     ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:47:26: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 1024 [-Wstringop-overread]
       47 |     size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1;                               \
          |                   ~~~~~~~^~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:155:5: note: in expansion of macro 'RESULT_STR'
      155 |     RESULT_STR(pcie_info_str);
          |     ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:132:8: note: source object declared here
      132 |   char pcie_info_str[1024];
          |        ^~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp: In function 'int aocl_mmd_read(int, aocl_mmd_op_t, size_t, void*, int, size_t)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:286:16: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 61 [-Wstringop-overread]
      286 |     if (strnlen(config_str, MAX_NAME_SIZE) <= len) {
          |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:246:8: note: source object declared here
      246 |   char config_str[] =
          |        ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp: In function 'int aocl_mmd_get_offline_info(aocl_mmd_offline_info_t, size_t, void*, size_t*)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:47:26: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 5 [-Wstringop-overread]
       47 |     size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1;                               \
          |                   ~~~~~~~^~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:95:5: note: in expansion of macro 'RESULT_STR'
       95 |     RESULT_STR(MMD_VERSION);
          |     ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:47:26: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 21 [-Wstringop-overread]
       47 |     size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1;                               \
          |                   ~~~~~~~^~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/fakegoodbsp.cpp:112:5: note: in expansion of macro 'RESULT_STR'
      112 |     RESULT_STR(ACL_VENDOR_NAME);
          |     ^~~~~~~~~~
    
  • test/fake_bsp/missingfuncbsp.cpp

    [109/113] /usr/bin/g++ -DCL_TARGET_OPENCL_VERSION=300 -DNOMINMAX -DUT_MALLOC_MACROS_DISABLED -DUT_NEW_MACROS_DISABLED -DUT_NEW_OVERRIDES_DISABLED -Dmissingfuncbsp_EXPORTS -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/src -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/include -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/include -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/. -g -fPIC -Wall -Wconversion -Wformat -Wformat-security -fno-strict-aliasing -fstack-protector -D_FORTIFY_SOURCE=2 -Og -std=gnu++17 -MD -MT test/fake_bsp/CMakeFiles/missingfuncbsp.dir/missingfuncbsp.cpp.o -MF test/fake_bsp/CMakeFiles/missingfuncbsp.dir/missingfuncbsp.cpp.o.d -o test/fake_bsp/CMakeFiles/missingfuncbsp.dir/missingfuncbsp.cpp.o -c /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp: In function 'int aocl_mmd_get_info(int, aocl_mmd_info_t, size_t, void*, size_t*)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:47:26: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 16 [-Wstringop-overread]
       47 |     size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1;                               \
          |                   ~~~~~~~^~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:140:5: note: in expansion of macro 'RESULT_STR'
      140 |     RESULT_STR(ACL_BOARD_NAME);
          |     ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:47:26: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 1024 [-Wstringop-overread]
       47 |     size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1;                               \
          |                   ~~~~~~~^~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:155:5: note: in expansion of macro 'RESULT_STR'
      155 |     RESULT_STR(pcie_info_str);
          |     ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:132:8: note: source object declared here
      132 |   char pcie_info_str[1024];
          |        ^~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp: In function 'int aocl_mmd_read(int, aocl_mmd_op_t, size_t, void*, int, size_t)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:271:16: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 61 [-Wstringop-overread]
      271 |     if (strnlen(config_str, MAX_NAME_SIZE) <= len) {
          |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:230:8: note: source object declared here
      230 |   char config_str[] =
          |        ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp: In function 'int aocl_mmd_get_offline_info(aocl_mmd_offline_info_t, size_t, void*, size_t*)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:47:26: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 5 [-Wstringop-overread]
       47 |     size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1;                               \
          |                   ~~~~~~~^~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:95:5: note: in expansion of macro 'RESULT_STR'
       95 |     RESULT_STR(MMD_VERSION);
          |     ^~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:47:26: warning: 'size_t strnlen(const char*, size_t)' specified bound 1204 exceeds source size 21 [-Wstringop-overread]
       47 |     size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1;                               \
          |                   ~~~~~~~^~~~~~~~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/fake_bsp/missingfuncbsp.cpp:112:5: note: in expansion of macro 'RESULT_STR'
      112 |     RESULT_STR(ACL_VENDOR_NAME);
          |     ^~~~~~~~~~
    

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions