[SCM] Samba Shared Repository - branch master updated

Matthias Dieter Wallnöfer mdw at samba.org
Mon Nov 8 04:22:01 MST 2010


The branch, master has been updated
       via  9aa0ed2 ldb:pyldb.c - "py_ldb_msg_element_get" - here we can safely use "unsigned int" for the element reference
       via  ef4861d ldb:pyldb.c - "py_ldb_contains" - return only "0" not found, "1" found, "-1" error
       via  7bdbfc9 ldb:pyldb.c - most of the times "time_t" is defined as "long int"
       via  9e5ca72 ldb:pyldb.c - fix some "Py_ssize_t" output warnings
       via  f6572e5 ldb:pyldb.c - use "Py_ssize_t" for counting list entries
       via  084c11d ldb:pyldb.c - fix indentation
       via  af84b6d s4:pydsdb.c - use "Py_ssize_t" for Python list counters
       via  9f2d215 s4:pydsdb.c - introduce Python 2.4 compatibility defines
      from  4b97e7c s4:objectguid/repl_meta_data LDB module - deny "objectGUID" updates

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9aa0ed2c3a74c6d72e42e4bc9e6077a50343fd38
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Sat Nov 6 17:50:25 2010 +0100

    ldb:pyldb.c - "py_ldb_msg_element_get" - here we can safely use "unsigned int" for the element reference
    
    We don't make use of "Py_List*" calls
    
    Autobuild-User: Matthias Dieter Wallnöfer <mdw at samba.org>
    Autobuild-Date: Mon Nov  8 11:21:27 UTC 2010 on sn-devel-104

commit ef4861d9263d1a17396c58abc7ad0c5837a1b52c
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Sat Nov 6 17:49:18 2010 +0100

    ldb:pyldb.c - "py_ldb_contains" - return only "0" not found, "1" found, "-1" error

commit 7bdbfc96037640dbd352e9ddab9c5e1ded9502fa
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Sat Nov 6 16:29:27 2010 +0100

    ldb:pyldb.c - most of the times "time_t" is defined as "long int"
    
    Therefore use a signed long int for conversions.
    
    http://stackoverflow.com/questions/471248/what-is-ultimately-a-time-t-typedef-to

commit 9e5ca72afbe74d88a1da33b6957b0914262f106c
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Sat Nov 6 18:03:22 2010 +0100

    ldb:pyldb.c - fix some "Py_ssize_t" output warnings

commit f6572e5ffc62ac41d3a180e0636129b40980f9dd
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Sat Nov 6 17:48:39 2010 +0100

    ldb:pyldb.c - use "Py_ssize_t" for counting list entries
    
    This seems to be the most appopriate type

commit 084c11d600e61b3c1b4c36b8440c67b37731d16c
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Sat Nov 6 16:29:06 2010 +0100

    ldb:pyldb.c - fix indentation

commit af84b6d32514525a52e0b6529b36a53943fb7a7a
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Sat Nov 6 16:28:33 2010 +0100

    s4:pydsdb.c - use "Py_ssize_t" for Python list counters
    
    Seems to be the most appropriate type

commit 9f2d21561b85edde541d7dbc69ee1fe58c029f81
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Sat Nov 6 17:54:36 2010 +0100

    s4:pydsdb.c - introduce Python 2.4 compatibility defines

-----------------------------------------------------------------------

Summary of changes:
 source4/dsdb/pydsdb.c   |   13 +++++++++-
 source4/lib/ldb/pyldb.c |   62 +++++++++++++++++++++++++---------------------
 2 files changed, 46 insertions(+), 29 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
index db2185f..2471548 100644
--- a/source4/dsdb/pydsdb.c
+++ b/source4/dsdb/pydsdb.c
@@ -28,6 +28,17 @@
 #include "auth/kerberos/kerberos.h"
 #include "librpc/rpc/pyrpc_util.h"
 
+/* There's no Py_ssize_t in 2.4, apparently */
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
+typedef int Py_ssize_t;
+typedef inquiry lenfunc;
+typedef intargfunc ssizeargfunc;
+#endif
+
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 /* FIXME: These should be in a header file somewhere, once we finish moving
  * away from SWIG .. */
 #define PyErr_LDB_OR_RAISE(py_ldb, ldb) \
@@ -319,7 +330,7 @@ static PyObject *py_dsdb_DsReplicaAttribute(PyObject *self, PyObject *args)
 	struct drsuapi_DsReplicaAttribute *attr;
 	TALLOC_CTX *tmp_ctx;
 	WERROR werr;
-	int i;
+	Py_ssize_t i;
 
 	if (!PyArg_ParseTuple(args, "OsO", &py_ldb, &ldap_display_name, &el_list)) {
 		return NULL;
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 7a6058f..acf8052 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -89,7 +89,7 @@ static PyObject *PyObject_FromLdbValue(struct ldb_context *ldb_ctx,
 static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
 {
 	PyObject *ret;
-	int i;
+	Py_ssize_t i;
 	if (result == NULL) {
 		Py_RETURN_NONE;
 	} 
@@ -113,7 +113,7 @@ static struct ldb_result *PyLdbResult_AsResult(TALLOC_CTX *mem_ctx,
 											   PyObject *obj)
 {
 	struct ldb_result *res;
-	int i;
+	Py_ssize_t i;
 
 	if (obj == Py_None)
 		return NULL;
@@ -493,7 +493,7 @@ static const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
 										const char *paramname)
 {
 	const char **ret;
-	int i;
+	Py_ssize_t i;
 	if (!PyList_Check(list)) {
 		PyErr_Format(PyExc_TypeError, "%s is not a list", paramname);
 		return NULL;
@@ -1425,13 +1425,14 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
 	struct ldb_context *ldb_ctx = PyLdb_AsLdbContext(self);
 	struct ldb_dn *dn;
 	struct ldb_result *result;
+	unsigned int count;
 	int ret;
-	int count;
 
 	if (!PyObject_AsDn(ldb_ctx, obj, ldb_ctx, &dn))
 		return -1;
 
-	ret = ldb_search(ldb_ctx, ldb_ctx, &result, dn, LDB_SCOPE_BASE, NULL, NULL);
+	ret = ldb_search(ldb_ctx, ldb_ctx, &result, dn, LDB_SCOPE_BASE, NULL,
+			 NULL);
 	if (ret != LDB_SUCCESS) {
 		PyErr_SetLdbError(PyExc_LdbError, ret, ldb_ctx);
 		return -1;
@@ -1441,7 +1442,13 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
 
 	talloc_free(result);
 
-	return count;
+	if (count == 1) {
+		return 1;
+	} else if (count == 0) {
+		return 0;
+	}
+
+	return -1;
 }
 
 static PySequenceMethods py_ldb_seq = {
@@ -1688,8 +1695,9 @@ PyTypeObject PyLdbModule = {
  * @return New ldb_message_element, allocated as child of mem_ctx
  */
 struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx,
-											   PyObject *set_obj, int flags,
-											   const char *attr_name)
+						      PyObject *set_obj,
+						      int flags,
+						      const char *attr_name)
 {
 	struct ldb_message_element *me;
 
@@ -1713,14 +1721,14 @@ struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx,
 		me->values[0].data = talloc_memdup(me, 
 			(uint8_t *)PyString_AsString(set_obj), me->values[0].length+1);
 	} else if (PySequence_Check(set_obj)) {
-		int i;
+		Py_ssize_t i;
 		me->num_values = PySequence_Size(set_obj);
 		me->values = talloc_array(me, struct ldb_val, me->num_values);
 		for (i = 0; i < me->num_values; i++) {
 			PyObject *obj = PySequence_GetItem(set_obj, i);
 			if (!PyString_Check(obj)) {
 				PyErr_Format(PyExc_TypeError,
-					     "Expected string as element %d in list", i);
+					     "Expected string as element %zd in list", i);
 				talloc_free(me);
 				return NULL;
 			}
@@ -1738,10 +1746,10 @@ struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx,
 }
 
 
-static PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx, 
-								 struct ldb_message_element *me)
+static PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
+					struct ldb_message_element *me)
 {
-	int i;
+	Py_ssize_t i;
 	PyObject *result;
 
 	/* Python << 2.5 doesn't have PySet_New and PySet_Add. */
@@ -1757,10 +1765,10 @@ static PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
 
 static PyObject *py_ldb_msg_element_get(PyLdbMessageElementObject *self, PyObject *args)
 {
-	int i;
-	if (!PyArg_ParseTuple(args, "i", &i))
+	unsigned int i;
+	if (!PyArg_ParseTuple(args, "I", &i))
 		return NULL;
-	if (i < 0 || i >= PyLdbMessageElement_AsMessageElement(self)->num_values)
+	if (i >= PyLdbMessageElement_AsMessageElement(self)->num_values)
 		Py_RETURN_NONE;
 
 	return PyObject_FromLdbValue(NULL, PyLdbMessageElement_AsMessageElement(self), 
@@ -1866,7 +1874,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
 	el = talloc_zero(mem_ctx, struct ldb_message_element);
 
 	if (py_elements != NULL) {
-		int i;
+		Py_ssize_t i;
 		if (PyString_Check(py_elements)) {
 			el->num_values = 1;
 			el->values = talloc_array(el, struct ldb_val, 1);
@@ -1880,8 +1888,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
 				PyObject *item = PySequence_GetItem(py_elements, i);
 				if (!PyString_Check(item)) {
 					PyErr_Format(PyExc_TypeError, 
-							"Expected string as element %d in list", 
-							i);
+						     "Expected string as element %zd in list", i);
 					talloc_free(mem_ctx);
 					return NULL;
 				}
@@ -1915,7 +1922,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
 static PyObject *py_ldb_msg_element_repr(PyLdbMessageElementObject *self)
 {
 	char *element_str = NULL;
-	int i;
+	Py_ssize_t i;
 	struct ldb_message_element *el = PyLdbMessageElement_AsMessageElement(self);
 	PyObject *ret;
 
@@ -1981,7 +1988,7 @@ static PyObject *py_ldb_msg_remove_attr(PyLdbMessageObject *self, PyObject *args
 static PyObject *py_ldb_msg_keys(PyLdbMessageObject *self)
 {
 	struct ldb_message *msg = PyLdbMessage_AsMessage(self);
-	int i, j = 0;
+	Py_ssize_t i, j = 0;
 	PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0));
 	if (msg->dn != NULL) {
 		PyList_SetItem(obj, j, PyString_FromString("dn"));
@@ -2041,9 +2048,8 @@ static PyObject *py_ldb_msg_get(PyLdbMessageObject *self, PyObject *args)
 static PyObject *py_ldb_msg_items(PyLdbMessageObject *self)
 {
 	struct ldb_message *msg = PyLdbMessage_AsMessage(self);
-	int i, j;
+	Py_ssize_t i, j = 0;
 	PyObject *l = PyList_New(msg->num_elements + (msg->dn == NULL?0:1));
-	j = 0;
 	if (msg->dn != NULL) {
 		PyList_SetItem(l, 0, Py_BuildValue("(sO)", "dn", PyLdbDn_FromDn(msg->dn)));
 		j++;
@@ -2588,14 +2594,14 @@ static PyObject *py_register_module(PyObject *module, PyObject *args)
 
 static PyObject *py_timestring(PyObject *module, PyObject *args)
 {
-	time_t t;
-	unsigned long val;
+	/* most times "time_t" is a signed integer type with 32 or 64 bit:
+	 * http://stackoverflow.com/questions/471248/what-is-ultimately-a-time-t-typedef-to */
+	long int t_val;
 	char *tresult;
 	PyObject *ret;
-	if (!PyArg_ParseTuple(args, "l", &val))
+	if (!PyArg_ParseTuple(args, "l", &t_val))
 		return NULL;
-	t = (time_t)val;
-	tresult = ldb_timestring(NULL, t);
+	tresult = ldb_timestring(NULL, (time_t) t_val);
 	ret = PyString_FromString(tresult);
 	talloc_free(tresult);
 	return ret;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list