summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-09-22 10:38:46 -0700
committerVolker Lendecke <vl@samba.org>2012-09-23 07:20:20 -0700
commitd0a0fb32929e26ea9dd30cb3e2cacff03f68b9d2 (patch)
tree08f8bcbfea25c5860f74af75932296269c8fd6f6
parent7305660c1139fc1d2dc40fb3324855ec7381eac5 (diff)
downloadsamba-d0a0fb32929e26ea9dd30cb3e2cacff03f68b9d2.tar.gz
samba-d0a0fb32929e26ea9dd30cb3e2cacff03f68b9d2.tar.bz2
samba-d0a0fb32929e26ea9dd30cb3e2cacff03f68b9d2.zip
s3-pylibsmb: Reduce the number of warnings
-rw-r--r--source3/libsmb/pylibsmb.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index 6641918e97..4225505dfa 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -50,6 +50,24 @@ static PyTypeObject *get_pytype(const char *module, const char *type)
return result;
}
+/*
+ * We're using "const char **" for keywords,
+ * PyArg_ParseTupleAndKeywords expects a "char **". Confine the
+ * inevitable warnings to just one place.
+ */
+static int ParseTupleAndKeywords(PyObject *args, PyObject *kw,
+ const char *format, const char **keywords,
+ ...)
+{
+ va_list a;
+ int ret;
+ va_start(a, keywords);
+ ret = PyArg_VaParseTupleAndKeywords(args, kw, format,
+ (char **)keywords, a);
+ va_end(a);
+ return ret;
+}
+
struct py_cli_thread;
struct py_cli_state {
@@ -375,8 +393,8 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args,
return -1;
}
- ret = PyArg_ParseTupleAndKeywords(
- args, kwds, "ss|O!", (char **)kwlist,
+ ret = ParseTupleAndKeywords(
+ args, kwds, "ss|O!", kwlist,
&host, &share, py_type_Credentials, &creds);
Py_DECREF(py_type_Credentials);
@@ -440,8 +458,8 @@ static PyObject *py_cli_create(struct py_cli_state *self, PyObject *args,
"ShareAccess", "CreateDisposition", "CreateOptions",
"SecurityFlags", NULL };
- if (!PyArg_ParseTupleAndKeywords(
- args, kwds, "s|IIIIIII", (char **)kwlist,
+ if (!ParseTupleAndKeywords(
+ args, kwds, "s|IIIIIII", kwlist,
&fname, &CreateFlags, &DesiredAccess, &FileAttributes,
&ShareAccess, &CreateDisposition, &CreateOptions,
&SecurityFlags)) {
@@ -505,8 +523,8 @@ static PyObject *py_cli_write(struct py_cli_state *self, PyObject *args,
static const char *kwlist[] = {
"fnum", "buffer", "offset", "mode", NULL };
- if (!PyArg_ParseTupleAndKeywords(
- args, kwds, "Is#K|I", (char **)kwlist,
+ if (!ParseTupleAndKeywords(
+ args, kwds, "Is#K|I", kwlist,
&fnum, &buf, &buflen, &offset, &mode)) {
return NULL;
}
@@ -541,8 +559,8 @@ static PyObject *py_cli_read(struct py_cli_state *self, PyObject *args,
static const char *kwlist[] = {
"fnum", "offset", "size", NULL };
- if (!PyArg_ParseTupleAndKeywords(
- args, kwds, "IKI", (char **)kwlist, &fnum, &offset,
+ if (!ParseTupleAndKeywords(
+ args, kwds, "IKI", kwlist, &fnum, &offset,
&size)) {
return NULL;
}
@@ -575,8 +593,8 @@ static PyObject *py_cli_ftruncate(struct py_cli_state *self, PyObject *args,
static const char *kwlist[] = {
"fnum", "size", NULL };
- if (!PyArg_ParseTupleAndKeywords(
- args, kwds, "IK", (char **)kwlist, &fnum, &size)) {
+ if (!ParseTupleAndKeywords(
+ args, kwds, "IK", kwlist, &fnum, &size)) {
return NULL;
}
@@ -606,8 +624,8 @@ static PyObject *py_cli_delete_on_close(struct py_cli_state *self,
static const char *kwlist[] = {
"fnum", "flag", NULL };
- if (!PyArg_ParseTupleAndKeywords(
- args, kwds, "II", (char **)kwlist, &fnum, &flag)) {
+ if (!ParseTupleAndKeywords(
+ args, kwds, "II", kwlist, &fnum, &flag)) {
return NULL;
}
@@ -647,8 +665,8 @@ static PyObject *py_cli_list(struct py_cli_state *self,
"mask", "attribute", "info_level", NULL
};
- if (!PyArg_ParseTupleAndKeywords(
- args, kwds, "s|II", (char **)kwlist,
+ if (!ParseTupleAndKeywords(
+ args, kwds, "s|II", kwlist,
&mask, &attribute, &info_level)) {
return NULL;
}