summaryrefslogtreecommitdiffstats
path: root/libmount/python
diff options
context:
space:
mode:
authorKarel Zak2013-08-20 11:32:49 +0200
committerKarel Zak2013-08-20 11:32:49 +0200
commit279a6d5f411708479620843469dd76274dc46bfa (patch)
tree72de41120d436d52379d3b85f06e3c54abda3540 /libmount/python
parentpylibmount: fs.c - cleanup, remove libmount private stuff (diff)
downloadkernel-qcow2-util-linux-279a6d5f411708479620843469dd76274dc46bfa.tar.gz
kernel-qcow2-util-linux-279a6d5f411708479620843469dd76274dc46bfa.tar.xz
kernel-qcow2-util-linux-279a6d5f411708479620843469dd76274dc46bfa.zip
pylibmount: use mnt_fs_set_userdata() rather than ->userdata
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/python')
-rw-r--r--libmount/python/fs.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/libmount/python/fs.c b/libmount/python/fs.c
index 70af46c1a..5868d41ce 100644
--- a/libmount/python/fs.c
+++ b/libmount/python/fs.c
@@ -636,7 +636,7 @@ static int Fs_init(FsObject *self, PyObject *args, PyObject *kwds)
mnt_fs_set_freq(self->fs, freq);
mnt_fs_set_passno(self->fs, passno);
- self->fs->userdata = (void *) self; /* store a pointer to self, convenient when resetting the table */
+ mnt_fs_set_userdata(self->fs, self); /* store a pointer to self, convenient when resetting the table */
return 0;
}
@@ -689,28 +689,32 @@ static PyObject *Fs_repr(FsObject *self)
PyObject *PyObjectResultFs(struct libmnt_fs *fs)
{
+ FsObject *result;
+
if (!fs) {
PyErr_SetString(LibmountError, "internal exception");
return NULL;
}
- if (fs->userdata) {
- Py_INCREF(fs->userdata);
- return (PyObject *)fs->userdata;
+
+ result = mnt_fs_get_userdata(fs);
+ if (result) {
+ Py_INCREF(result);
+ return (PyObject *) result;
}
- FsObject *result = PyObject_New(FsObject, &FsType);
+ /* Creating an encapsualing object: increment the refcount, so that code
+ * such as tab.next_fs() doesn't call the destructor, which would free
+ * our fs struct as well
+ */
+ result = PyObject_New(FsObject, &FsType);
if (!result) {
UL_RaiseExc(ENOMEM);
return NULL;
}
- /* Creating an encapsualing object: increment the refcount, so that code
- * such as:
- * tab.next_fs()
- * doesn't call the destructor, which would free our fs struct as well
- */
+
Py_INCREF(result);
result->fs = fs;
- result->fs->userdata = (void *) result;
+ mnt_fs_set_userdata(fs, result);
return (PyObject *) result;
}
@@ -731,7 +735,7 @@ static PyObject *Fs_copy_fs(FsObject *self, PyObject *args, PyObject *kwds)
} else if (dest == Py_None) { /* create new object */
FsObject *result = PyObject_New(FsObject, &FsType);
result->fs = mnt_copy_fs(NULL, self->fs);
- result->fs->userdata = (void *)result; /* keep a pointer to encapsulating object */
+ mnt_fs_set_userdata(result->fs, result); /* keep a pointer to encapsulating object */
return (PyObject *)result;
}