1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 #ifndef _UTIL_H 3 #define _UTIL_H 4 5 #include <objtool/warn.h> 6 7 #define snprintf_check(str, size, format, args...) \ 8 ({ \ 9 int __ret = snprintf(str, size, format, args); \ 10 if (__ret < 0) \ 11 ERROR_GLIBC("snprintf"); \ 12 else if (__ret >= size) \ 13 ERROR("snprintf() failed for '" format "'", args); \ 14 else \ 15 __ret = 0; \ 16 __ret; \ 17 }) 18 19 #endif /* _UTIL_H */ 20