apply some code analyzer recommendations

This commit is contained in:
2024-11-20 20:01:58 +03:00
parent b65bf5e640
commit a3e88f792d
8 changed files with 24 additions and 38 deletions

View File

@@ -31,7 +31,7 @@ void CInterface::autoConnect(PIObject * o, const PIString & prefix) {
// piCout << "func" << it.value().func_name;
}
PIVector<CDType *> cl = C.root().children();
piForeachC(CDType * c, cl) {
for (const auto * c: cl) {
PIString cp = prefix + c->pathString().join("_");
if (cp.isEmpty()) continue;
if (!eh_map.contains(cp)) continue;

View File

@@ -112,7 +112,7 @@ void CDCore::cd_read(CDSection * cd, PIIODevice * d) {
initRoot(cd);
raiseChangedGlobal(cd->cd_type_);
/*PIVector<PIIODevice * > ds = connection.allDevices();
piForeach(PIIODevice * d, ds) {
for (PIIODevice * d: ds) {
if (d)
piCoutObj << d->constructFullPath() << d->isOpened();
}*/
@@ -377,7 +377,7 @@ void CDCore::xTimerTick() {
} else {
ba = makeHeader(CD_XValues, 0);
ba << x_selected;
piForeachC(PIDeque<int> & p, x_selected) {
for (const auto & p: x_selected) {
x_[p].writeX(ba);
}
// piCout << "x app" << x_selected.size();
@@ -471,7 +471,7 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
ba >> x_selected;
// piCout << "X req" << x_selected.size();
x_.setSelectedX(false);
piForeachC(PIDeque<int> & p, x_selected) {
for (const auto & p: x_selected) {
x_[p].x_enabled = true;
}
x_mutex.unlock();
@@ -481,7 +481,7 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
PIVector<PIDeque<int>> x_vals;
ba >> x_vals;
x_mutex.lock();
piForeachC(PIDeque<int> & p, x_vals) {
for (const auto & p: x_vals) {
x_[p].readX(ba);
}
x_mutex.unlock();
@@ -558,7 +558,7 @@ PIString CDCore::pathToString(const PIDeque<int> & p) {
PIDeque<int> CDCore::stringToPath(const PIString & p) {
PIDeque<int> ret;
PIStringList sl = p.split(".");
piForeachC(PIString & s, sl)
for (const auto & s: sl)
ret << s.toInt();
return ret;
}
@@ -568,7 +568,7 @@ void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & da
// piCoutObj << "dataReceived" << from << data.size();
PIIODevice * d = connection.deviceByName("cd");
if (d && d == connection.deviceByFullPath(from)) {
if (data.size() >= sizeof(4)) {
if (data.size() >= sizeof(int)) {
PIByteArray ba = data;
uchar header = ba.take_front();
if (header == header_transfer) {

View File

@@ -3,24 +3,12 @@
#include "cdutils_core.h"
#include "piconfig.h"
#include "pievaluator.h"
#include "pifile.h"
using namespace CDUtils;
const int cd_x_history_max_size = 4000;
CDType::CDType() {
index_ = -1;
value_d = 0.;
value_i = 0;
value_b = calculated = x_enabled = false;
cd_type_ = cdNull;
parent = 0;
avg_size = 1;
mode_ = rmode_ = X_Current;
}
CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t) {
index_ = i;

View File

@@ -73,7 +73,7 @@ public:
X_All_Avg
};
CDType();
CDType() {}
CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t);
CDType & operator=(double x);
@@ -113,19 +113,20 @@ public:
protected:
bool calculate(PIEvaluator * e, PIVector<const CDType *> stack = PIVector<const CDType *>());
PIVariantTypes::Enum parseEnumComment(PIString c);
cdT cd_type_;
int index_;
cdT cd_type_ = cdNull;
int index_ = -1;
PIString name_, type_;
PIString value_s, formula_, comment_, error_;
PIVariantTypes::Enum enum_values;
CDSection * parent;
CDSection * parent = nullptr;
PIDeque<int> path_;
double value_d;
int value_i;
bool value_b, calculated, x_enabled;
double value_d = 0.;
int value_i = 0;
bool value_b = false, calculated = false, x_enabled = false;
PIVector<double> avg_h;
int avg_size;
XMode mode_, rmode_;
int avg_size = 1;
XMode mode_ = X_Current, rmode_ = X_Current;
};
@@ -163,10 +164,7 @@ public:
PIString alias;
protected:
CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_) {
cd = k_;
s = s_;
}
CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_): cd(k_), s(s_) {}
CDType & getByName(const PIString & name_);
CDType & getByPath(const PIDeque<int> & path_);
void write(PIIODevice * d, const PIString & prefix = PIString());

View File

@@ -140,7 +140,7 @@ bool QCDCore::bindWidget(QWidget * w) {
return false;
}
PIVector<CDType *> ak = K.root().children();
piForeachC(CDType * k, ak) {
for (const auto * k: ak) {
if (!on.endsWith(PI2QString(k->pathString().join("_")))) continue;
if (bindWidget(w, *k)) return true;
}

View File

@@ -344,7 +344,7 @@ void CDView::cd_receivedX() {
X.lock();
PIVector<PIDeque<int>> xl = X.enabledList();
// piCout << "X" << xl.size();
piForeachC(PIDeque<int> & x, xl) {
for (const auto & x: xl) {
CDType & t(X[x]);
// piCout << t;
// piCout << t.path();