Base: C++ core guidelines: init variables

This commit is contained in:
wmayer
2023-08-24 14:21:05 +02:00
committed by wwmayer
parent 53a4fb14c3
commit 010dca8303
43 changed files with 622 additions and 626 deletions

View File

@@ -84,7 +84,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
Quantity *self = getQuantityPtr();
PyErr_Clear(); // set by PyArg_ParseTuple()
PyObject *object;
PyObject *object{};
if (PyArg_ParseTuple(args,"O!",&(Base::QuantityPy::Type), &object)) {
*self = *(static_cast<Base::QuantityPy*>(object)->getQuantityPtr());
return 0;
@@ -127,7 +127,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear(); // set by PyArg_ParseTuple()
char* string;
char* string{};
if (PyArg_ParseTuple(args,"et", "utf-8", &string)) {
QString qstr = QString::fromUtf8(string);
PyMem_Free(string);
@@ -164,7 +164,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject* QuantityPy::getUserPreferred(PyObject* /*args*/)
{
QString uus;
double factor;
double factor{};
Py::Tuple res(3);
QString uss = getQuantityPtr()->getUserString(factor,uus);
@@ -183,14 +183,14 @@ PyObject* QuantityPy::getValueAs(PyObject *args)
// first try Quantity
if (!quant.isValid()) {
PyObject *object;
PyObject *object{};
if (PyArg_ParseTuple(args,"O!",&(Base::QuantityPy::Type), &object)) {
quant = * static_cast<Base::QuantityPy*>(object)->getQuantityPtr();
}
}
if (!quant.isValid()) {
PyObject *object;
PyObject *object{};
PyErr_Clear();
if (PyArg_ParseTuple(args,"O!",&(Base::UnitPy::Type), &object)) {
quant.setUnit(*static_cast<Base::UnitPy*>(object)->getUnitPtr());
@@ -199,8 +199,8 @@ PyObject* QuantityPy::getValueAs(PyObject *args)
}
if (!quant.isValid()) {
PyObject *object;
double value;
PyObject *object{};
double value{};
PyErr_Clear();
if (PyArg_ParseTuple(args,"dO!",&value, &(Base::UnitPy::Type), &object)) {
quant.setUnit(*static_cast<Base::UnitPy*>(object)->getUnitPtr());
@@ -235,7 +235,7 @@ PyObject* QuantityPy::getValueAs(PyObject *args)
if (!quant.isValid()) {
PyErr_Clear();
char* string;
char* string{};
if (PyArg_ParseTuple(args,"et", "utf-8", &string)) {
QString qstr = QString::fromUtf8(string);
PyMem_Free(string);
@@ -417,7 +417,7 @@ PyObject * QuantityPy::number_remainder_handler (PyObject *self, PyObject *other
return nullptr;
}
double d1, d2;
double d1{}, d2{};
Base::Quantity *a = static_cast<QuantityPy*>(self) ->getQuantityPtr();
d1 = a->getValue();
@@ -641,7 +641,7 @@ void QuantityPy::setFormat(Py::Dict arg)
if (fmtstr.size() != 1)
throw Py::ValueError("Invalid format character");
bool ok;
bool ok = false;
fmt.format = Base::QuantityFormat::toFormat(fmtstr[0], &ok);
if (!ok)
throw Py::ValueError("Invalid format character");