2eb900
From 50f7c251523f6be3be3426aa6499e5495a18b442 Mon Sep 17 00:00:00 2001
2eb900
From: Mark Hamzy <hamzy@us.ibm.com>
2eb900
Date: Wed, 6 Aug 2014 14:06:45 -0500
2eb900
Subject: [PATCH] use Py_ssize_t
2eb900
2eb900
>Starting with Python 2.5 the type of the length argument can be controlled by
2eb900
>defining the macro PY_SSIZE_T_CLEAN before including Python.h. If the macro is
2eb900
>defined, length is a Py_ssize_t rather than an int.
2eb900
2eb900
dmalcolm@redhat.com says:
2eb900
"and IIRC that *does* in fact affect "et#" and the other hash-suffixed codes
2eb900
i.e. PyArg_ParseTupleAndKeywords was expecting bufsize to be a Py_ssize_t, not an int."
2eb900
2eb900
So, changing size_t to Py_ssize_t and ints used as sizes to Py_ssize_t.
2eb900
2eb900
---
2eb900
 xattr.c | 24 ++++++++++++------------
2eb900
 1 file changed, 12 insertions(+), 12 deletions(-)
2eb900
2eb900
diff --git a/xattr.c b/xattr.c
2eb900
index cc1fa44..2529e90 100644
2eb900
--- a/xattr.c
2eb900
+++ b/xattr.c
2eb900
@@ -193,7 +193,7 @@ static int merge_ns(const char *ns, const char *name,
2eb900
     return 0;
2eb900
 }
2eb900
 
2eb900
-static ssize_t _list_obj(target_t *tgt, char *list, size_t size) {
2eb900
+static Py_ssize_t _list_obj(target_t *tgt, char *list, Py_ssize_t size) {
2eb900
     if(tgt->type == T_FD)
2eb900
         return flistxattr(tgt->fd, list, size);
2eb900
     else if (tgt->type == T_LINK)
2eb900
@@ -202,8 +202,8 @@ static ssize_t _list_obj(target_t *tgt, char *list, size_t size) {
2eb900
         return listxattr(tgt->name, list, size);
2eb900
 }
2eb900
 
2eb900
-static ssize_t _get_obj(target_t *tgt, const char *name, void *value,
2eb900
-                        size_t size) {
2eb900
+static Py_ssize_t _get_obj(target_t *tgt, const char *name, void *value,
2eb900
+                        Py_ssize_t size) {
2eb900
     if(tgt->type == T_FD)
2eb900
         return fgetxattr(tgt->fd, name, value, size);
2eb900
     else if (tgt->type == T_LINK)
2eb900
@@ -213,7 +213,7 @@ static ssize_t _get_obj(target_t *tgt, const char *name, void *value,
2eb900
 }
2eb900
 
2eb900
 static int _set_obj(target_t *tgt, const char *name,
2eb900
-                    const void *value, size_t size, int flags) {
2eb900
+                    const void *value, Py_ssize_t size, int flags) {
2eb900
     if(tgt->type == T_FD)
2eb900
         return fsetxattr(tgt->fd, name, value, size, flags);
2eb900
     else if (tgt->type == T_LINK)
2eb900
@@ -242,7 +242,7 @@ static int _remove_obj(target_t *tgt, const char *name) {
2eb900
 
2eb900
 */
2eb900
 const char *matches_ns(const char *ns, const char *name) {
2eb900
-    size_t ns_size;
2eb900
+    Py_ssize_t ns_size;
2eb900
     if (ns == NULL || *ns == '\0')
2eb900
         return name;
2eb900
     ns_size = strlen(ns);
2eb900
@@ -275,7 +275,7 @@ pygetxattr(PyObject *self, PyObject *args)
2eb900
     int nofollow = 0;
2eb900
     char *attrname = NULL;
2eb900
     char *buf;
2eb900
-    ssize_t nalloc, nret;
2eb900
+    Py_ssize_t nalloc, nret;
2eb900
     PyObject *res;
2eb900
 
2eb900
     /* Parse the arguments */
2eb900
@@ -352,7 +352,7 @@ xattr_get(PyObject *self, PyObject *args, PyObject *keywds)
2eb900
     const char *fullname;
2eb900
     char *buf;
2eb900
     const char *ns = NULL;
2eb900
-    ssize_t nalloc, nret;
2eb900
+    Py_ssize_t nalloc, nret;
2eb900
     PyObject *res;
2eb900
     static char *kwlist[] = {"item", "name", "nofollow", "namespace", NULL};
2eb900
 
2eb900
@@ -451,7 +451,7 @@ get_all(PyObject *self, PyObject *args, PyObject *keywds)
2eb900
     const char *ns = NULL;
2eb900
     char *buf_list, *buf_val;
2eb900
     const char *s;
2eb900
-    ssize_t nalloc, nlist, nval;
2eb900
+    Py_ssize_t nalloc, nlist, nval;
2eb900
     PyObject *mylist;
2eb900
     target_t tgt;
2eb900
     static char *kwlist[] = {"item", "nofollow", "namespace", NULL};
2eb900
@@ -604,7 +604,7 @@ pysetxattr(PyObject *self, PyObject *args)
2eb900
     int nofollow = 0;
2eb900
     char *attrname = NULL;
2eb900
     char *buf = NULL;
2eb900
-    int bufsize;
2eb900
+    Py_ssize_t bufsize;
2eb900
     int nret;
2eb900
     int flags = 0;
2eb900
     target_t tgt;
2eb900
@@ -670,7 +670,7 @@ xattr_set(PyObject *self, PyObject *args, PyObject *keywds)
2eb900
     int nofollow = 0;
2eb900
     char *attrname = NULL;
2eb900
     char *buf = NULL;
2eb900
-    int bufsize;
2eb900
+    Py_ssize_t bufsize;
2eb900
     int nret;
2eb900
     int flags = 0;
2eb900
     target_t tgt;
2eb900
@@ -856,7 +856,7 @@ pylistxattr(PyObject *self, PyObject *args)
2eb900
 {
2eb900
     char *buf;
2eb900
     int nofollow=0;
2eb900
-    ssize_t nalloc, nret;
2eb900
+    Py_ssize_t nalloc, nret;
2eb900
     PyObject *myarg;
2eb900
     PyObject *mylist;
2eb900
     Py_ssize_t nattrs;
2eb900
@@ -956,7 +956,7 @@ xattr_list(PyObject *self, PyObject *args, PyObject *keywds)
2eb900
 {
2eb900
     char *buf;
2eb900
     int nofollow = 0;
2eb900
-    ssize_t nalloc, nret;
2eb900
+    Py_ssize_t nalloc, nret;
2eb900
     PyObject *myarg;
2eb900
     PyObject *res;
2eb900
     const char *ns = NULL;
2eb900
-- 
2eb900
2.0.0
2eb900