From 8d769244071e0e7779ecaf181ffd6634eff7a37e Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sat, 2 May 2015 01:17:37 +0200 Subject: [PATCH] Fix sign-compare warning in merge_ns() Thanks to travis-ci - the code does what seems an unsafe sign compare, but actually it is a valid comparison (we test/handle the `< 0` case as well, which is the only way the comparison could be invalid). To silence this, do an explicit (safe) cast. --- xattr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xattr.c b/xattr.c index 7173922..b0fdb77 100644 --- a/xattr.c +++ b/xattr.c @@ -174,13 +174,15 @@ static int merge_ns(const char *ns, const char *name, const char **result, char **buf) { if(ns != NULL && *ns != '\0') { int cnt; + /* The value of new_size is related to/must be kept in-sync + with the format string below */ size_t new_size = strlen(ns) + 1 + strlen(name) + 1; if((*buf = PyMem_Malloc(new_size)) == NULL) { PyErr_NoMemory(); return -1; } cnt = snprintf(*buf, new_size, "%s.%s", ns, name); - if(cnt > new_size || cnt < 0) { + if((size_t) cnt > new_size || cnt < 0) { PyErr_SetString(PyExc_ValueError, "can't format the attribute name"); PyMem_Free(*buf); -- 2.39.5