206 lines
5.9 KiB
Diff
206 lines
5.9 KiB
Diff
commit 12b631a6768e6f2a2005ef8ea91c0afbc2455c54
|
|
Author: Andy Grover <agrover@redhat.com>
|
|
Date: Mon Oct 15 13:34:43 2012 -0700
|
|
|
|
python-lvm: whitespace and Yoda conditionals
|
|
|
|
Signed-off-by: Andy Grover <agrover@redhat.com>
|
|
---
|
|
python/liblvm.c | 50 ++++++++++++++++++++++++--------------------------
|
|
1 file changed, 24 insertions(+), 26 deletions(-)
|
|
|
|
diff --git a/python/liblvm.c b/python/liblvm.c
|
|
index 4518cf4..8a73ced 100644
|
|
--- a/python/liblvm.c
|
|
+++ b/python/liblvm.c
|
|
@@ -75,7 +75,7 @@ liblvm_get_last_error(void)
|
|
|
|
LVM_VALID();
|
|
|
|
- if((info = PyTuple_New(2)) == NULL)
|
|
+ if ((info = PyTuple_New(2)) == NULL)
|
|
return NULL;
|
|
|
|
PyTuple_SetItem(info, 0, PyInt_FromLong((long) lvm_errno(libh)));
|
|
@@ -174,7 +174,7 @@ liblvm_lvm_vgname_from_pvid(PyObject *self, PyObject *arg)
|
|
if (!PyArg_ParseTuple(arg, "s", &pvid))
|
|
return NULL;
|
|
|
|
- if((vgname = lvm_vgname_from_pvid(libh, pvid)) == NULL) {
|
|
+ if ((vgname = lvm_vgname_from_pvid(libh, pvid)) == NULL) {
|
|
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
|
|
return NULL;
|
|
}
|
|
@@ -193,7 +193,7 @@ liblvm_lvm_vgname_from_device(PyObject *self, PyObject *arg)
|
|
if (!PyArg_ParseTuple(arg, "s", &device))
|
|
return NULL;
|
|
|
|
- if((vgname = lvm_vgname_from_device(libh, device)) == NULL) {
|
|
+ if ((vgname = lvm_vgname_from_device(libh, device)) == NULL) {
|
|
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
|
|
return NULL;
|
|
}
|
|
@@ -233,7 +233,7 @@ liblvm_lvm_config_reload(void)
|
|
|
|
LVM_VALID();
|
|
|
|
- if((rval = lvm_config_reload(libh)) == -1) {
|
|
+ if ((rval = lvm_config_reload(libh)) == -1) {
|
|
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
|
|
return NULL;
|
|
}
|
|
@@ -250,7 +250,7 @@ liblvm_lvm_scan(void)
|
|
|
|
LVM_VALID();
|
|
|
|
- if((rval = lvm_scan(libh)) == -1) {
|
|
+ if ((rval = lvm_scan(libh)) == -1) {
|
|
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
|
|
return NULL;
|
|
}
|
|
@@ -603,7 +603,7 @@ get_property(struct lvm_property_value *prop)
|
|
PyObject *pytuple;
|
|
PyObject *setable;
|
|
|
|
- if( !prop->is_valid ) {
|
|
+ if (!prop->is_valid) {
|
|
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
|
|
return NULL;
|
|
}
|
|
@@ -612,7 +612,7 @@ get_property(struct lvm_property_value *prop)
|
|
if (!pytuple)
|
|
return NULL;
|
|
|
|
- if( prop->is_integer ) {
|
|
+ if (prop->is_integer) {
|
|
PyTuple_SET_ITEM(pytuple, 0, Py_BuildValue("K", prop->value.integer));
|
|
} else {
|
|
PyTuple_SET_ITEM(pytuple, 0, PyString_FromString(prop->value.string));
|
|
@@ -661,11 +661,11 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
|
|
|
|
lvm_property = lvm_vg_get_property(self->vg, property_name);
|
|
|
|
- if( !lvm_property.is_valid ) {
|
|
+ if (!lvm_property.is_valid ) {
|
|
goto lvmerror;
|
|
}
|
|
|
|
- if(PyObject_IsInstance(variant_type_arg, (PyObject*)&PyString_Type)) {
|
|
+ if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyString_Type)) {
|
|
|
|
if (!lvm_property.is_string) {
|
|
PyErr_Format(PyExc_ValueError, "Property requires string value");
|
|
@@ -676,7 +676,7 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
|
|
leak when calling into set_property, need to verify*/
|
|
string_value = strdup(PyString_AsString(variant_type_arg));
|
|
lvm_property.value.string = string_value;
|
|
- if(!lvm_property.value.string) {
|
|
+ if (!lvm_property.value.string) {
|
|
PyErr_NoMemory();
|
|
goto bail;
|
|
}
|
|
@@ -688,14 +688,12 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
|
|
goto bail;
|
|
}
|
|
|
|
- if(PyObject_IsInstance(variant_type_arg, (PyObject*)&PyInt_Type)) {
|
|
+ if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyInt_Type)) {
|
|
int temp_py_int = PyInt_AsLong(variant_type_arg);
|
|
|
|
/* -1 could be valid, need to see if an exception was gen. */
|
|
- if( -1 == temp_py_int ) {
|
|
- if( PyErr_Occurred() ) {
|
|
- goto bail;
|
|
- }
|
|
+ if (temp_py_int == -1 && PyErr_Occurred()) {
|
|
+ goto bail;
|
|
}
|
|
|
|
if (temp_py_int < 0) {
|
|
@@ -704,10 +702,10 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
|
|
}
|
|
|
|
lvm_property.value.integer = temp_py_int;
|
|
- } else if(PyObject_IsInstance(variant_type_arg, (PyObject*)&PyLong_Type)){
|
|
+ } else if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyLong_Type)){
|
|
/* This will fail on negative numbers */
|
|
unsigned long long temp_py_long = PyLong_AsUnsignedLongLong(variant_type_arg);
|
|
- if( (unsigned long long)-1 == temp_py_long ) {
|
|
+ if (temp_py_long == (unsigned long long)-1) {
|
|
goto bail;
|
|
}
|
|
|
|
@@ -718,11 +716,11 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
|
|
}
|
|
}
|
|
|
|
- if( -1 == lvm_vg_set_property(self->vg, property_name, &lvm_property) ) {
|
|
+ if (lvm_vg_set_property(self->vg, property_name, &lvm_property) == -1) {
|
|
goto lvmerror;
|
|
}
|
|
|
|
- if( -1 == lvm_vg_write(self->vg)) {
|
|
+ if (lvm_vg_write(self->vg) == -1) {
|
|
goto lvmerror;
|
|
}
|
|
|
|
@@ -734,7 +732,7 @@ lvmerror:
|
|
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
|
|
bail:
|
|
free(string_value);
|
|
- if( variant_type_arg ) {
|
|
+ if (variant_type_arg) {
|
|
Py_DECREF(variant_type_arg);
|
|
variant_type_arg = NULL;
|
|
}
|
|
@@ -933,13 +931,13 @@ liblvm_lvm_lv_from_N(vgobject *self, PyObject *arg, lv_fetch_by_N method)
|
|
return NULL;
|
|
|
|
lv = method(self->vg, id);
|
|
- if( !lv ) {
|
|
+ if (!lv) {
|
|
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
|
|
return NULL;
|
|
}
|
|
|
|
rc = PyObject_New(lvobject, &LibLVMlvType);
|
|
- if( !rc ) {
|
|
+ if (!rc) {
|
|
return NULL;
|
|
}
|
|
|
|
@@ -972,13 +970,13 @@ liblvm_lvm_pv_from_N(vgobject *self, PyObject *arg, pv_fetch_by_N method)
|
|
return NULL;
|
|
|
|
pv = method(self->vg, id);
|
|
- if( !pv ) {
|
|
+ if (!pv) {
|
|
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
|
|
return NULL;
|
|
}
|
|
|
|
rc = PyObject_New(pvobject, &LibLVMpvType);
|
|
- if( !rc ) {
|
|
+ if (!rc) {
|
|
return NULL;
|
|
}
|
|
|
|
@@ -1255,7 +1253,7 @@ liblvm_lvm_lv_list_lvsegs(lvobject *lv)
|
|
LV_VALID(lv);
|
|
|
|
lvsegs = lvm_lv_list_lvsegs(lv->lv);
|
|
- if(!lvsegs) {
|
|
+ if (!lvsegs) {
|
|
return Py_BuildValue("()");
|
|
}
|
|
|
|
@@ -1371,7 +1369,7 @@ liblvm_lvm_lv_list_pvsegs(pvobject *pv)
|
|
PV_VALID(pv);
|
|
|
|
pvsegs = lvm_pv_list_pvsegs(pv->pv);
|
|
- if(!pvsegs) {
|
|
+ if (!pvsegs) {
|
|
return Py_BuildValue("()");
|
|
}
|
|
|