From 7ab3b462374bdd3cdc6dd85005b58c591b891961 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@debian.org>
Date: Fri, 13 May 2016 23:18:00 +0200
Subject: [PATCH] Imported Upstream version 0.5.6

---
 NEWS                      | 13 +++++++++++++
 PKG-INFO                  |  2 +-
 README.rst                |  2 +-
 doc/conf.py               |  4 ++--
 pyxattr.egg-info/PKG-INFO |  2 +-
 setup.py                  |  4 ++--
 xattr.c                   | 12 +++++++++---
 7 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/NEWS b/NEWS
index b4a099b..526c085 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,19 @@
 News
 ====
 
+Version 0.5.6
+-------------
+
+*released Sat, 09 Apr 2016*
+
+Small bugfix release:
+
+* Fixes some sign-compare warnings
+* Fixes potential name truncation in merge_ns()
+* Fixes building on systems which don't have ENODATA
+
+Tested with Python 2.7.11, Python 3.5.1 and PyPy 5.0.1.
+
 Version 0.5.5
 -------------
 
diff --git a/PKG-INFO b/PKG-INFO
index 191a253..da37e9b 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pyxattr
-Version: 0.5.5
+Version: 0.5.6
 Summary: Filesystem extended attributes for python
 Home-page: http://pyxattr.k1024.org/
 Author: Iustin Pop
diff --git a/README.rst b/README.rst
index 4d6aa5b..b3b314c 100644
--- a/README.rst
+++ b/README.rst
@@ -6,7 +6,7 @@ to the extended attributes for filesystem objects available in some
 operating systems.
 
 Downloads: go to http://pyxattr.k1024.org/downloads/. Latest
-version is 0.5.5. The source repository is either at
+version is 0.5.6. The source repository is either at
 http://git.k1024.org/pyxattr.git or at
 https://github.com/iustin/pyxattr.
 
diff --git a/doc/conf.py b/doc/conf.py
index fd9d7c0..77f6b68 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -48,9 +48,9 @@ copyright = u'2002, 2003, 2006, 2008, 2012, 2013, 2014, 2015, Iustin Pop'
 # built documents.
 #
 # The short X.Y version.
-version = '0.5.5'
+version = '0.5.6'
 # The full version, including alpha/beta/rc tags.
-release = '0.5.5'
+release = '0.5.6'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/pyxattr.egg-info/PKG-INFO b/pyxattr.egg-info/PKG-INFO
index 191a253..da37e9b 100644
--- a/pyxattr.egg-info/PKG-INFO
+++ b/pyxattr.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pyxattr
-Version: 0.5.5
+Version: 0.5.6
 Summary: Filesystem extended attributes for python
 Home-page: http://pyxattr.k1024.org/
 Author: Iustin Pop
diff --git a/setup.py b/setup.py
index edcf5ae..f580b19 100755
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ except ImportError:
 long_desc = """This is a C extension module for Python which
 implements extended attributes manipulation. It is a wrapper on top
 of the attr C library - see attr(5)."""
-version = "0.5.5"
+version = "0.5.6"
 author = "Iustin Pop"
 author_email = "iustin@k1024.org"
 macros = [
@@ -29,7 +29,7 @@ setup(name = "pyxattr",
       ext_modules = [Extension("xattr", ["xattr.c"],
                                libraries=["attr"],
                                define_macros=macros,
-                               extra_compile_args=["-Wall", "-Werror"],
+                               extra_compile_args=["-Wall", "-Werror", "-Wsign-compare"],
                                )],
       test_suite = "test",
       platforms = ["Linux"],
diff --git a/xattr.c b/xattr.c
index 7173922..c792df3 100644
--- a/xattr.c
+++ b/xattr.c
@@ -174,15 +174,17 @@ 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");
+                            "unexpected: can't format the attribute name");
             PyMem_Free(*buf);
             return -1;
         }
@@ -549,7 +551,11 @@ get_all(PyObject *self, PyObject *args, PyObject *keywds)
                     buf_val = buf_val_tmp;
                     nalloc = realloc_size;
                     continue;
-                } else if(errno == ENODATA || errno == ENOATTR) {
+                } else if(
+#ifdef ENODATA
+                          errno == ENODATA ||
+#endif
+                          errno == ENOATTR) {
                     /* this attribute has gone away since we queried
                        the attribute list */
                     missing = 1;
-- 
2.39.5