Underscore prefix is reserved for the compiler and standard library so
we should not use it for our helpers.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 58 ++++++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 7574141..42b46fb 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -19,11 +19,11 @@
#define MODULE_NAME "sanlock"
#define BIND_ERROR -1000
/* Functions prototypes */
-static void __set_exception(int en, char *msg);
+static void set_sanlock_error(int en, char *msg);
static int __parse_resource(PyObject *obj, struct sanlk_resource **res_ret);
static void set_error(PyObject *exception, const char* format, PyObject* obj);
/* Sanlock module */
PyDoc_STRVAR(pydoc_sanlock, "\
@@ -34,11 +34,11 @@ of the GNU General Public License v2 or (at your option) any later
version.");
/* Sanlock exception */
static PyObject *py_exception;
static void
-__set_exception(int en, char *msg)
+set_sanlock_error(int en, char *msg)
{
const char *err_name;
PyObject *exc_tuple;
if (en < 0 && en > -200) {
@@ -321,11 +321,11 @@ py_register(PyObject *self __unused, PyObject *args)
Py_BEGIN_ALLOW_THREADS
sanlockfd = sanlock_register();
Py_END_ALLOW_THREADS
if (sanlockfd < 0) {
- __set_exception(sanlockfd, "Sanlock registration failed");
+ set_sanlock_error(sanlockfd, "Sanlock registration failed");
return NULL;
}
return Py_BuildValue("i", sanlockfd);
}
@@ -354,11 +354,11 @@ py_get_alignment(PyObject *self __unused, PyObject *args)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_direct_align(&disk);
Py_END_ALLOW_THREADS
if (rv < 0) {
- __set_exception(rv, "Unable to get device alignment");
+ set_sanlock_error(rv, "Unable to get device alignment");
goto finally;
}
finally:
Py_XDECREF(path);
@@ -440,11 +440,11 @@ py_init_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_direct_init(&ls, NULL, max_hosts, num_hosts, use_aio);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock lockspace init failure");
+ set_sanlock_error(rv, "Sanlock lockspace init failure");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -493,11 +493,11 @@ py_init_resource(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_direct_init(NULL, res, max_hosts, num_hosts, use_aio);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock resource init failure");
+ set_sanlock_error(rv, "Sanlock resource init failure");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -554,11 +554,11 @@ py_write_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_write_lockspace(&ls, max_hosts, 0, io_timeout);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock lockspace write failure");
+ set_sanlock_error(rv, "Sanlock lockspace write failure");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -610,11 +610,11 @@ py_read_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_read_lockspace(&ls, 0, &io_timeout);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock lockspace read failure");
+ set_sanlock_error(rv, "Sanlock lockspace read failure");
goto finally;
}
/* fill the information dictionary */
ls_info = Py_BuildValue(
@@ -686,11 +686,11 @@ py_read_resource(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_read_resource(rs, 0);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock resource read failure");
+ set_sanlock_error(rv, "Sanlock resource read failure");
goto finally;
}
/* prepare the dictionary holding the information */
rs_info = Py_BuildValue(
@@ -770,11 +770,11 @@ py_write_resource(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_write_resource(rs, max_hosts, num_hosts, flags);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock resource write failure");
+ set_sanlock_error(rv, "Sanlock resource write failure");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -829,11 +829,11 @@ py_add_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_add_lockspace_timeout(&ls, flags, iotimeout);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock lockspace add failure");
+ set_sanlock_error(rv, "Sanlock lockspace add failure");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -899,11 +899,11 @@ finally:
Py_RETURN_FALSE;
} else if (rv == -EINPROGRESS) {
Py_RETURN_NONE;
}
- __set_exception(rv, "Sanlock lockspace inquire failure");
+ set_sanlock_error(rv, "Sanlock lockspace inquire failure");
return NULL;
}
/* rem_lockspace */
PyDoc_STRVAR(pydoc_rem_lockspace, "\
@@ -955,11 +955,11 @@ py_rem_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_rem_lockspace(&ls, flags);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock lockspace remove failure");
+ set_sanlock_error(rv, "Sanlock lockspace remove failure");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -989,11 +989,11 @@ py_get_lockspaces(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_get_lockspaces(&lss, &lss_count, 0);
Py_END_ALLOW_THREADS
if (rv < 0) {
- __set_exception(rv, "Sanlock get lockspaces failure");
+ set_sanlock_error(rv, "Sanlock get lockspaces failure");
goto exit_fail;
}
/* prepare the dictionary holding the information */
if ((ls_list = PyList_New(0)) == NULL)
@@ -1067,11 +1067,11 @@ py_get_hosts(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_get_hosts(PyBytes_AsString(lockspace), host_id, &hss,
&hss_count, 0);
Py_END_ALLOW_THREADS
if (rv < 0) {
- __set_exception(rv, "Sanlock get hosts failure");
+ set_sanlock_error(rv, "Sanlock get hosts failure");
goto finally;
}
ls_list = __hosts_to_list(hss, hss_count);
@@ -1111,11 +1111,11 @@ py_acquire(PyObject *self __unused, PyObject *args, PyObject
*keywds)
goto finally;
}
/* check if any of the slkfd or pid parameters was given */
if (sanlockfd == -1 && pid == -1) {
- __set_exception(EINVAL, "Invalid slkfd and pid values");
+ set_sanlock_error(EINVAL, "Invalid slkfd and pid values");
goto finally;
}
/* parse and check sanlock resource */
if (__parse_resource(disks, &res) < 0) {
@@ -1134,22 +1134,22 @@ py_acquire(PyObject *self __unused, PyObject *args, PyObject
*keywds)
/* prepare the resource version */
if (version != Py_None) {
res->flags |= SANLK_RES_LVER;
res->lver = pyinteger_as_unsigned_long_long_mask(version);
if (res->lver == (uint64_t)-1) {
- __set_exception(EINVAL, "Unable to convert the version value");
+ set_sanlock_error(EINVAL, "Unable to convert the version value");
goto finally;
}
}
/* acquire sanlock resource (gil disabled) */
Py_BEGIN_ALLOW_THREADS
rv = sanlock_acquire(sanlockfd, pid, 0, 1, &res, 0);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock resource not acquired");
+ set_sanlock_error(rv, "Sanlock resource not acquired");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -1197,11 +1197,11 @@ py_release(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_release(sanlockfd, pid, 0, 1, &res);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock resource not released");
+ set_sanlock_error(rv, "Sanlock resource not released");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -1254,22 +1254,22 @@ py_request(PyObject *self __unused, PyObject *args, PyObject
*keywds)
flags = SANLK_REQUEST_NEXT_LVER;
} else {
res->flags |= SANLK_RES_LVER;
res->lver = pyinteger_as_unsigned_long_long_mask(version);
if (res->lver == (uint64_t)-1) {
- __set_exception(EINVAL, "Unable to convert the version value");
+ set_sanlock_error(EINVAL, "Unable to convert the version value");
goto finally;
}
}
/* request sanlock resource (gil disabled) */
Py_BEGIN_ALLOW_THREADS
rv = sanlock_request(flags, action, res);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Sanlock request not submitted");
+ set_sanlock_error(rv, "Sanlock request not submitted");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -1333,11 +1333,11 @@ py_read_resource_owners(PyObject *self __unused, PyObject *args,
PyObject *keywd
Py_BEGIN_ALLOW_THREADS
rv = sanlock_read_resource_owners(res, 0, &hss, &hss_count);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Unable to read resource owners");
+ set_sanlock_error(rv, "Unable to read resource owners");
goto finally;
}
ls_list = __hosts_to_list(hss, hss_count);
@@ -1371,11 +1371,11 @@ parse_killpath_item(PyObject *item, char *kpargs, size_t *kplen)
if (p[i] == ' ' || p[i] == '\\') arg_len++;
}
/* adding 2 for the space separator ' ' and the '\0' terminator */
if (*kplen + arg_len + 2 > SANLK_HELPER_ARGS_LEN) {
- __set_exception(EINVAL, "Killpath arguments are too long");
+ set_sanlock_error(EINVAL, "Killpath arguments are too long");
goto finally;
}
/* adding the space separator between arguments */
if (*kplen > 0) {
@@ -1421,11 +1421,11 @@ py_killpath(PyObject *self __unused, PyObject *args, PyObject
*keywds)
goto finally;
}
/* checking the path length */
if (PyBytes_Size(path) + 1 > SANLK_HELPER_PATH_LEN) {
- __set_exception(EINVAL, "Killpath path argument too long");
+ set_sanlock_error(EINVAL, "Killpath path argument too long");
goto finally;
}
num_args = PyList_Size(argslist);
memset(kpargs, 0, SANLK_HELPER_ARGS_LEN);
@@ -1442,11 +1442,11 @@ py_killpath(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_killpath(sanlockfd, 0, PyBytes_AsString(path), kpargs);
Py_END_ALLOW_THREADS
if (rv != 0) {
- __set_exception(rv, "Killpath script not configured");
+ set_sanlock_error(rv, "Killpath script not configured");
goto finally;
}
finally:
Py_XDECREF(path);
@@ -1493,11 +1493,11 @@ py_reg_event(PyObject *self __unused, PyObject *args)
Py_BEGIN_ALLOW_THREADS
fd = sanlock_reg_event(PyBytes_AsString(lockspace), NULL /* event */, 0 /* flags
*/);
Py_END_ALLOW_THREADS
if (fd < 0) {
- __set_exception(fd, "Unable to register event fd");
+ set_sanlock_error(fd, "Unable to register event fd");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -1545,11 +1545,11 @@ py_get_event(PyObject *self __unused, PyObject *args)
if (rv == -EAGAIN)
break;
if (rv != 0) {
- __set_exception(rv, "Unable to get events");
+ set_sanlock_error(rv, "Unable to get events");
goto exit_fail;
}
if ((item = PyDict_New()) == NULL)
goto exit_fail;
@@ -1636,11 +1636,11 @@ py_end_event(PyObject *self __unused, PyObject *args)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_end_event(fd, PyBytes_AsString(lockspace), 0 /* flags */);
Py_END_ALLOW_THREADS
if (rv < 0) {
- __set_exception(rv, "Unable to unregister event fd");
+ set_sanlock_error(rv, "Unable to unregister event fd");
goto finally;
}
finally:
Py_XDECREF(lockspace);
@@ -1721,11 +1721,11 @@ py_set_event(PyObject *self __unused, PyObject *args, PyObject
*keywds)
Py_BEGIN_ALLOW_THREADS
rv = sanlock_set_event(PyBytes_AsString(lockspace), &he, flags);
Py_END_ALLOW_THREADS
if (rv < 0) {
- __set_exception(rv, "Unable to set event");
+ set_sanlock_error(rv, "Unable to set event");
goto finally;
}
finally:
Py_XDECREF(lockspace);
--
2.17.2