1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-05 12:19:48 +03:00

util: add _dm_strncpy

Add internal inline function wrapper for dm_strncpy().
Use it for calls where we test the result.
Avoids emitting warnings in Coverity for unchecked usage.
This commit is contained in:
Zdenek Kabelac 2024-04-04 18:41:42 +02:00
parent 5c0ade35e2
commit 295e632e81
2 changed files with 14 additions and 0 deletions

View File

@ -35,6 +35,13 @@
#define uninitialized_var(x) x = x
#endif
/* Use wrapper for checked results */
static inline __attribute__((warn_unused_result))
int _dm_strncpy(char *dest, const char *src, size_t n)
{
return dm_strncpy(dest, src, n);
}
/*
* GCC 3.4 adds a __builtin_clz, which uses the count leading zeros (clz)
* instruction on arches that have one. Provide a fallback using shifts

View File

@ -17,6 +17,13 @@
#include <inttypes.h>
/* Use wrapper for checked results */
static inline __attribute__((warn_unused_result))
int _dm_strncpy(char *dest, const char *src, size_t n)
{
return dm_strncpy(dest, src, n);
}
#define min(a, b) ({ typeof(a) _a = (a); \
typeof(b) _b = (b); \
(void) (&_a == &_b); \