1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright 2023 Red Hat 4 */ 5 6 #include "string-utils.h" 7 8 char *vdo_append_to_buffer(char *buffer, char *buf_end, const char *fmt, ...) 9 { 10 va_list args; 11 size_t n; 12 13 va_start(args, fmt); 14 n = vsnprintf(buffer, buf_end - buffer, fmt, args); 15 if (n >= (size_t) (buf_end - buffer)) 16 buffer = buf_end; 17 else 18 buffer += n; 19 va_end(args); 20 21 return buffer; 22 } 23