pmem / issues

Old issues repo for PMDK.
http://pmem.io
13 stars 7 forks source link

pmdk does not build on gcc 8.1.1 #876

Closed kkajrewicz closed 6 years ago

kkajrewicz commented 6 years ago

My distro: Fedora 28 gcc 8.1.1

Logs: build_log.txt

(...)
In file included from benchmark.hpp:64,
                 from blk.cpp:37:
In function ‘int util_safe_strcpy(char*, const char*, size_t)’,
    inlined from ‘int blk_exit(benchmark*, benchmark_args*)’ at blk.cpp:596:22:
../common/util.h:161:9: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound 4096 equals destination size [-Werror=stringop-truncation]
  strncpy(dst, src, max_length);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
(...)

Following solution fixes the building issue:

static inline int
util_safe_strcpy(char *dst, const char *src, size_t max_length)
       if (max_length == 0)
               return -1;

       if (strlen(src) + 1 > max_length)
               return -1;

       strncpy(dst, src, max_length);

       return 0;
 }

Found on 1.4-rc4-360-g14296ee8

marcinslusarz commented 6 years ago

Fix merged. Please verify.

kkajrewicz commented 6 years ago

Verified on 1.4-rc4-468-g856e5e14b