1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

o lvm_snprintf

Could everyone please use this from now on.
This commit is contained in:
Joe Thornber 2001-12-17 14:04:10 +00:00
parent 27f6cd0a88
commit 39b633c1de

31
lib/misc/lvm-string.h Normal file
View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the LGPL.
*/
#ifndef _LVM_STRING_H
#define _LVM_STRING_H
#include <stdarg.h>
/*
* Different versions of glibc have different
* return values for over full buffers.
*/
static inline int lvm_snprintf(char *str, size_t size, const char *format, ...)
{
int n;
va_list ap;
va_start(ap, format);
n = vsnprintf(str, size, format, ap);
va_end(ap);
if (n < 0 || n == size)
return -1;
return n;
}
#endif