summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2022-12-15 13:12:32 +0100
committerJose M. Guisado <jguisado@soleta.eu>2022-12-15 17:37:07 +0100
commit975acaf5498223318ed2c61bf896dc982c1801f4 (patch)
treea50ba8c48ed685e21d9b17faa35fea0d24154511
parenteaf98290cf111f1427d1c3adeea688b90452802a (diff)
coding style: line breaks
Only two line breaks separate copyright notice from source. For the rest of the source file any function declaration or similar block is separated with a line break from any other block. Except when a python function definition is previously followed by a docstring #define block.
-rw-r--r--context.c16
-rw-r--r--fdisk.c1
-rw-r--r--label.c7
-rw-r--r--partition.c10
-rw-r--r--parttype.c3
5 files changed, 26 insertions, 11 deletions
diff --git a/context.c b/context.c
index c93cd36..326c0c4 100644
--- a/context.c
+++ b/context.c
@@ -16,7 +16,6 @@ static PyMemberDef Context_members[] = {
{ NULL }
};
-
static void Context_dealloc(ContextObject *self)
{
if (!self->cxt) /* if init fails */
@@ -77,7 +76,6 @@ static int Context_init(ContextObject *self, PyObject *args, PyObject *kwds)
return 0;
}
-
#define Context_assign_device_HELP "assign_device(device)\n\n" \
"Open the device, discovery topology, geometry, detect disklabel " \
"and switch the current label driver to reflect the probing result. "
@@ -102,6 +100,7 @@ static PyObject *Context_assign_device(ContextObject *self, PyObject *args, PyOb
Py_INCREF(Py_None);
return Py_None;
}
+
#define Context_partition_to_string_HELP "partition_to_string(pa, field)\n\n" \
"Retrieve partition field using fdisk_partition_to_string." \
"Field constants are available as FDISK_LABEL_*"
@@ -126,6 +125,7 @@ static PyObject *Context_partition_to_string(ContextObject *self, PyObject *args
return ret;
}
+
#define Context_create_disklabel_HELP "create_disklabel(label)\n\n" \
"Creates a new disk label of type name . If name is NULL, " \
"then it will create a default system label type, either SUN or DOS."
@@ -145,6 +145,7 @@ static PyObject *Context_create_disklabel(ContextObject *self, PyObject *args, P
Py_RETURN_NONE;
}
+
#define Context_write_disklabel_HELP "write_disklabel()\n\n" \
"This function wipes the device (if enabled by fdisk_enable_wipe()) " \
"and then it writes in-memory changes to disk. Be careful!"
@@ -160,6 +161,7 @@ static PyObject *Context_write_disklabel(ContextObject *self, PyObject *args, Py
Py_RETURN_NONE;
}
+
#define Context_add_partition_HELP "add_partition(fdisk.Partition)\n\n" \
"Adds partition to context. Returns partno of the new partition."
static PyObject *Context_add_partition(ContextObject *self, PyObject *args, PyObject *kwds)
@@ -186,6 +188,7 @@ static PyObject *Context_add_partition(ContextObject *self, PyObject *args, PyOb
return Py_BuildValue("n", partno);
}
+
static PyMethodDef Context_methods[] = {
{"assign_device", (PyCFunction)Context_assign_device, METH_VARARGS, Context_assign_device_HELP},
{"partition_to_string", (PyCFunction)Context_partition_to_string, METH_VARARGS, Context_partition_to_string_HELP},
@@ -195,19 +198,21 @@ static PyMethodDef Context_methods[] = {
{NULL}
};
-
static PyObject *Context_get_nsectors(ContextObject *self)
{
return PyLong_FromUnsignedLong(fdisk_get_nsectors(self->cxt));
}
+
static PyObject *Context_get_sector_size(ContextObject *self)
{
return PyLong_FromUnsignedLong(fdisk_get_sector_size(self->cxt));
}
+
static PyObject *Context_get_devname(ContextObject *self)
{
return PyObjectResultStr(fdisk_get_devname(self->cxt));
}
+
static PyObject *Context_get_label(ContextObject *self)
{
struct fdisk_context *cxt = self->cxt;
@@ -218,10 +223,12 @@ static PyObject *Context_get_label(ContextObject *self)
Py_RETURN_NONE;
}
}
+
static PyObject *Context_get_nparts(ContextObject *self)
{
return PyLong_FromLong(fdisk_table_get_nents(self->tb));
}
+
static PyObject *Context_get_partitions(ContextObject *self)
{
PyObject *p, *list = PyList_New(0); /* XXX: null if failed*/
@@ -244,10 +251,12 @@ static PyObject *Context_get_partitions(ContextObject *self)
return list;
}
+
static PyObject *Context_get_size_unit(ContextObject *self)
{
return PyLong_FromLong(fdisk_get_size_unit(self->cxt));
}
+
static int Context_set_size_unit(ContextObject *self, PyObject *value, void *closure)
{
int szunit;
@@ -273,6 +282,7 @@ static int Context_set_size_unit(ContextObject *self, PyObject *value, void *clo
return 0;
}
+
static PyGetSetDef Context_getseters[] = {
{"nsectors", (getter)Context_get_nsectors, NULL, "context number of sectors", NULL},
{"sector_size", (getter)Context_get_sector_size, NULL, "context sector size", NULL},
diff --git a/fdisk.c b/fdisk.c
index 909d95c..d7d3fe4 100644
--- a/fdisk.c
+++ b/fdisk.c
@@ -34,7 +34,6 @@ static PyMethodDef FdiskMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
-
static struct PyModuleDef fdiskmodule = {
PyModuleDef_HEAD_INIT,
"fdisk", /* name of module */
diff --git a/label.c b/label.c
index a4bd265..50f0372 100644
--- a/label.c
+++ b/label.c
@@ -12,12 +12,10 @@
#include "fdisk.h"
-
static PyMemberDef Label_members[] = {
{ NULL }
};
-
static void Label_dealloc(LabelObject *self)
{
Py_TYPE(self)->tp_free((PyObject *) self);
@@ -80,6 +78,7 @@ static PyObject *Label_get_parttype_from_code(LabelObject *self, PyObject *args,
return PyObjectResultPartType(ptype);
}
+
#define Label_get_parttype_from_string_HELP "get_parttype_from_string(uuid)\n\n" \
"Search by string for partition type in label-specific table."
static PyObject *Label_get_parttype_from_string(LabelObject *self, PyObject *args, PyObject *kwds)
@@ -100,21 +99,23 @@ static PyObject *Label_get_parttype_from_string(LabelObject *self, PyObject *arg
return PyObjectResultPartType(ptype);
}
+
static PyMethodDef Label_methods[] = {
{"get_parttype_from_code", (PyCFunction)Label_get_parttype_from_code, METH_VARARGS, Label_get_parttype_from_code_HELP},
{"get_parttype_from_string", (PyCFunction)Label_get_parttype_from_string, METH_VARARGS, Label_get_parttype_from_string_HELP},
{NULL}
};
-
static PyObject *Label_get_type(LabelObject *self)
{
return PyLong_FromLong(fdisk_label_get_type(self->lb));
}
+
static PyObject *Label_get_name(LabelObject *self)
{
return PyObjectResultStr(fdisk_label_get_name(self->lb));
}
+
static PyGetSetDef Label_getseters[] = {
{"type", (getter)Label_get_type, NULL, "label type", NULL},
{"name", (getter)Label_get_name, NULL, "label name", NULL},
diff --git a/partition.c b/partition.c
index 45c391a..5284869 100644
--- a/partition.c
+++ b/partition.c
@@ -12,12 +12,10 @@
#include "fdisk.h"
-
static PyMemberDef Partition_members[] = {
{ NULL }
};
-
static void Partition_dealloc(PartitionObject *self)
{
if (self->pa)
@@ -78,12 +76,10 @@ static int Partition_init(PartitionObject *self, PyObject *args, PyObject *kwds)
return 0;
}
-
static PyMethodDef Partition_methods[] = {
{NULL}
};
-
static PyObject *Partition_get_partno(PartitionObject *self)
{
if (fdisk_partition_has_partno(self->pa)) {
@@ -91,6 +87,7 @@ static PyObject *Partition_get_partno(PartitionObject *self)
}
Py_RETURN_NONE;
}
+
static int Partition_set_partno(PartitionObject *self, PyObject *value, void *closure)
{
size_t num;
@@ -113,6 +110,7 @@ static int Partition_set_partno(PartitionObject *self, PyObject *value, void *cl
return 0;
}
+
static PyObject *Partition_get_size(PartitionObject *self)
{
if (fdisk_partition_has_size(self->pa)) {
@@ -120,6 +118,7 @@ static PyObject *Partition_get_size(PartitionObject *self)
}
Py_RETURN_NONE;
}
+
static int Partition_set_size(PartitionObject *self, PyObject *value, void *closure)
{
uint64_t sectors;
@@ -143,6 +142,7 @@ static int Partition_set_size(PartitionObject *self, PyObject *value, void *clos
return 0;
}
+
static PyObject *Partition_get_type(PartitionObject *self)
{
struct fdisk_parttype *t;
@@ -153,6 +153,7 @@ static PyObject *Partition_get_type(PartitionObject *self)
Py_RETURN_NONE;
}
+
static int Partition_set_type(PartitionObject *self, PyObject *value, void *closure)
{
if (!value) {
@@ -173,6 +174,7 @@ static int Partition_set_type(PartitionObject *self, PyObject *value, void *clos
return 0;
}
+
static PyGetSetDef Partition_getseters[] = {
{"partno", (getter)Partition_get_partno, (setter)Partition_set_partno, "partition number", NULL},
{"size", (getter)Partition_get_size, (setter)Partition_set_size, "number of sectors", NULL},
diff --git a/parttype.c b/parttype.c
index e3c6238..cbdae82 100644
--- a/parttype.c
+++ b/parttype.c
@@ -9,6 +9,7 @@
* Author: Jose M. Guisado <jguisado@soleta.eu>
*/
+
#include "fdisk.h"
static PyMemberDef PartType_members[] = {
@@ -28,10 +29,12 @@ static PyObject *PartType_get_name(PartTypeObject *self)
{
return PyObjectResultStr(fdisk_parttype_get_name(self->type));
}
+
static PyObject *PartType_get_code(PartTypeObject *self)
{
return PyLong_FromUnsignedLong(fdisk_parttype_get_code(self->type));
}
+
static PyGetSetDef PartType_getseters[] = {
{"name", (getter)PartType_get_name, NULL, "parttype human readable name", NULL},
{"code", (getter)PartType_get_code, NULL, "parttype DOS code", NULL},