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