1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-04 09:18:36 +03:00

util: add dm_strncpy_check

Add inline wrapper function for dm_strncpy().
We will use this function for tested calls of this function.
This will make sure Coverity will not be emitting warnings
for every unchecked use of this function.
This commit is contained in:
Zdenek Kabelac 2024-04-04 18:41:42 +02:00
parent 17cf661867
commit 051f9c52c4
2 changed files with 13 additions and 0 deletions

View File

@ -35,6 +35,12 @@
#define uninitialized_var(x) x = x
#endif
/* Use wrapper for checked results */
static inline __attribute__((warn_unused_result))
int dm_strncpy_check(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_check(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); \