Skip to content

Fix warnings in CppUTest #123

Open
Open
@pcolberg

Description

@pcolberg

Warnings from Ubuntu 22.04 debug build with GCC 11.2, which are all related to integer type mismatches, e.g., using int where size_t would be appropriate. These have likely all been addressed upstream, though updating to the newest version is not straightforward due to our customizations for multi-threading.

  • lib/CppUTest/src/Failure.cpp

    [33/113] /usr/bin/g++ -DNOMINMAX -DUT_MALLOC_MACROS_DISABLED -DUT_NEW_MACROS_DISABLED -DUT_NEW_OVERRIDES_DISABLED -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/include -g -Wall -Wconversion -Wformat -Wformat-security -fno-strict-aliasing -fstack-protector -D_FORTIFY_SOURCE=2 -Og -std=gnu++17 -MD -MT lib/CppUTest/CMakeFiles/CppUTest.dir/src/Failure.cpp.o -MF lib/CppUTest/CMakeFiles/CppUTest.dir/src/Failure.cpp.o.d -o lib/CppUTest/CMakeFiles/CppUTest.dir/src/Failure.cpp.o -c /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/Failure.cpp
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/Failure.cpp: In member function 'virtual int Failure::getLineNumber() const':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/Failure.cpp:73:16: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
       73 |         return lineNumber;
          |                ^~~~~~~~~~
    
  • lib/CppUTest/src/MemoryLeakAllocator.cpp

    [35/113] /usr/bin/g++ -DNOMINMAX -DUT_MALLOC_MACROS_DISABLED -DUT_NEW_MACROS_DISABLED -DUT_NEW_OVERRIDES_DISABLED -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/include -g -Wall -Wconversion -Wformat -Wformat-security -fno-strict-aliasing -fstack-protector -D_FORTIFY_SOURCE=2 -Og -std=gnu++17 -MD -MT lib/CppUTest/CMakeFiles/CppUTest.dir/src/MemoryLeakAllocator.cpp.o -MF lib/CppUTest/CMakeFiles/CppUTest.dir/src/MemoryLeakAllocator.cpp.o.d -o lib/CppUTest/CMakeFiles/CppUTest.dir/src/MemoryLeakAllocator.cpp.o -c /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakAllocator.cpp
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakAllocator.cpp: In function 'char* checkedMalloc(size_t)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakAllocator.cpp:34:52: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
       34 |         char* mem = (char*) PlatformSpecificMalloc(size);
          |                                                    ^~~~
    
  • lib/CppUTest/src/MemoryLeakDetector.cpp

    [36/113] /usr/bin/g++ -DNOMINMAX -DUT_MALLOC_MACROS_DISABLED -DUT_NEW_MACROS_DISABLED -DUT_NEW_OVERRIDES_DISABLED -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/include -g -Wall -Wconversion -Wformat -Wformat-security -fno-strict-aliasing -fstack-protector -D_FORTIFY_SOURCE=2 -Og -std=gnu++17 -MD -MT lib/CppUTest/CMakeFiles/CppUTest.dir/src/MemoryLeakDetector.cpp.o -MF lib/CppUTest/CMakeFiles/CppUTest.dir/src/MemoryLeakDetector.cpp.o.d -o lib/CppUTest/CMakeFiles/CppUTest.dir/src/MemoryLeakDetector.cpp.o -c /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakDetector.cpp
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakDetector.cpp: In member function 'int MemoryLeakDetectorTable::hash(char*)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakDetector.cpp:176:34: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
      176 |         return ((size_t) memory) % hash_prime;
          |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakDetector.cpp: In function 'int calculateIntAlignedSize(size_t)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakDetector.cpp:300:53: warning: conversion from 'long unsigned int' to 'int' may change value [-Wconversion]
      300 |         return (sizeof(int) - (size % sizeof(int))) + size;
          |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakDetector.cpp: In member function 'char* MemoryLeakDetector::reallocateMemoryAndExtraInfo(char*, size_t)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/MemoryLeakDetector.cpp:322:58: warning: conversion from 'long unsigned int' to 'unsigned int' may change value [-Wconversion]
      321 |         return (char*) PlatformSpecificRealloc(memory, calculateIntAlignedSize(size
          |                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      322 |                         + memory_corruption_buffer_size) + sizeof(MemoryLeakDetectorNode));
          |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  • lib/CppUTest/src/SimpleString.cpp

    [38/113] /usr/bin/g++ -DNOMINMAX -DUT_MALLOC_MACROS_DISABLED -DUT_NEW_MACROS_DISABLED -DUT_NEW_OVERRIDES_DISABLED -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/include -g -Wall -Wconversion -Wformat -Wformat-security -fno-strict-aliasing -fstack-protector -D_FORTIFY_SOURCE=2 -Og -std=gnu++17 -MD -MT lib/CppUTest/CMakeFiles/CppUTest.dir/src/SimpleString.cpp.o -MF lib/CppUTest/CMakeFiles/CppUTest.dir/src/SimpleString.cpp.o.d -o lib/CppUTest/CMakeFiles/CppUTest.dir/src/SimpleString.cpp.o -c /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/SimpleString.cpp
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/SimpleString.cpp: In member function 'void SimpleString::split(const SimpleString&, SimpleStringCollection&) const':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/SimpleString.cpp:138:31: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
      138 |                 int len = str - prev;
          |                           ~~~~^~~~~~
    
  • lib/CppUTest/src/UtestPlatformGcc.cpp

    [45/113] /usr/bin/g++ -DNOMINMAX -DUT_MALLOC_MACROS_DISABLED -DUT_NEW_MACROS_DISABLED -DUT_NEW_OVERRIDES_DISABLED -I/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/include -g -Wall -Wconversion -Wformat -Wformat-security -fno-strict-aliasing -fstack-protector -D_FORTIFY_SOURCE=2 -Og -std=gnu++17 -MD -MT lib/CppUTest/CMakeFiles/CppUTest.dir/src/UtestPlatformGcc.cpp.o -MF lib/CppUTest/CMakeFiles/CppUTest.dir/src/UtestPlatformGcc.cpp.o.d -o lib/CppUTest/CMakeFiles/CppUTest.dir/src/UtestPlatformGcc.cpp.o -c /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/UtestPlatformGcc.cpp
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/UtestPlatformGcc.cpp: In function 'long int TimeInMillisImplementation()':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/UtestPlatformGcc.cpp:295:47: warning: conversion from '__suseconds_t' {aka 'long int'} to 'double' may change value [-Wconversion]
      295 |         return (tv.tv_sec * 1000) + (long)(tv.tv_usec * 0.001);
          |                                            ~~~^~~~~~~
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/UtestPlatformGcc.cpp: In function 'int PlatformSpecificStrLen(const char*)':
    /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/lib/CppUTest/src/UtestPlatformGcc.cpp:337:17: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
      337 |    return strlen(str);
          |           ~~~~~~^~~~~
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions