mirror of https://github.com/xzeldon/htop.git
Use size_t as len type for xSnprintf
Like the C snprintf function
This commit is contained in:
parent
3d15ba5197
commit
d9224c66a4
4
XUtils.c
4
XUtils.c
|
@ -184,13 +184,13 @@ int xAsprintf(char** strp, const char* fmt, ...) {
|
|||
return r;
|
||||
}
|
||||
|
||||
int xSnprintf(char* buf, int len, const char* fmt, ...) {
|
||||
int xSnprintf(char* buf, size_t len, const char* fmt, ...) {
|
||||
va_list vl;
|
||||
va_start(vl, fmt);
|
||||
int n = vsnprintf(buf, len, fmt, vl);
|
||||
va_end(vl);
|
||||
|
||||
if (n < 0 || n >= len) {
|
||||
if (n < 0 || (size_t)n >= len) {
|
||||
fail();
|
||||
}
|
||||
|
||||
|
|
2
XUtils.h
2
XUtils.h
|
@ -59,7 +59,7 @@ ATTR_FORMAT(printf, 2, 3)
|
|||
int xAsprintf(char** strp, const char* fmt, ...);
|
||||
|
||||
ATTR_FORMAT(printf, 3, 4)
|
||||
int xSnprintf(char* buf, int len, const char* fmt, ...);
|
||||
int xSnprintf(char* buf, size_t len, const char* fmt, ...);
|
||||
|
||||
char* xStrdup(const char* str) ATTR_NONNULL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue