pvs fix warnings

git-svn-id: svn://db.shs.com.ru/pip@280 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2016-11-07 13:07:46 +00:00
parent bf2f224eb9
commit a393f93ee1
21 changed files with 84 additions and 64 deletions

View File

@@ -480,51 +480,51 @@ void PIConsole::run() {
toUpperLeft();
if (max_y < cvars.size()) max_y = cvars.size();
j = 0;
piForeachC (Variable & tv, cvars) {
piForeachC (Variable & tv_, cvars) {
if (j > height - 3) continue;
j++;
moveRight(cx);
if (tv.type == 15) {
if (tv_.type == 15) {
newLine();
continue;
}
moveRight(tv.offset);
moveRight(tv_.offset);
const void * ptr = 0;
if (tv.remote) {
if (tv.type == 0) {
if (tv_.remote) {
if (tv_.type == 0) {
rstr.clear();
rba = tv.rdata;
rba = tv_.rdata;
rba >> rstr;
rstr.trim();
ptr = &rstr;
} else
ptr = tv.rdata.data();
ptr = tv_.rdata.data();
} else
ptr = tv.ptr;
switch (tv.type) {
case 0: clen = printValue(ptr != 0 ? *(const PIString*)ptr : PIString(), tv.format); break;
case 1: clen = printValue(ptr != 0 ? *(const bool*)ptr : false, tv.format); break;
case 2: clen = printValue(ptr != 0 ? *(const int*)ptr : 0, tv.format); break;
case 3: clen = printValue(ptr != 0 ? *(const long*)ptr : 0l, tv.format); break;
case 4: clen = printValue(ptr != 0 ? *(const char*)ptr : char(0), tv.format); break;
case 5: clen = printValue(ptr != 0 ? *(const float*)ptr : 0.f, tv.format); break;
case 6: clen = printValue(ptr != 0 ? *(const double*)ptr : 0., tv.format); break;
case 7: clen = printValue(ptr != 0 ? *(const short*)ptr : short(0), tv.format); break;
case 8: clen = printValue(ptr != 0 ? *(const uint*)ptr : 0u, tv.format); break;
case 9: clen = printValue(ptr != 0 ? *(const ulong*)ptr : 0ul, tv.format); break;
case 10: clen = printValue(ptr != 0 ? *(const ushort*)ptr : ushort(0), tv.format); break;
case 11: clen = printValue(ptr != 0 ? *(const uchar*)ptr : uchar(0), tv.format); break;
case 12: clen = printValue(ptr != 0 ? *(const llong*)ptr : 0l, tv.format); break;
case 13: clen = printValue(ptr != 0 ? *(const ullong*)ptr: 0ull, tv.format); break;
case 20: clen = printValue(ptr != 0 ? *(const PISystemTime*)ptr: PISystemTime(), tv.format); break;
case 14: clen = printValue(bitsValue(ptr, tv.bitFrom, tv.bitCount), tv.format); break;
ptr = tv_.ptr;
switch (tv_.type) {
case 0: clen = printValue(ptr != 0 ? *(const PIString*)ptr : PIString(), tv_.format); break;
case 1: clen = printValue(ptr != 0 ? *(const bool*)ptr : false, tv_.format); break;
case 2: clen = printValue(ptr != 0 ? *(const int*)ptr : 0, tv_.format); break;
case 3: clen = printValue(ptr != 0 ? *(const long*)ptr : 0l, tv_.format); break;
case 4: clen = printValue(ptr != 0 ? *(const char*)ptr : char(0), tv_.format); break;
case 5: clen = printValue(ptr != 0 ? *(const float*)ptr : 0.f, tv_.format); break;
case 6: clen = printValue(ptr != 0 ? *(const double*)ptr : 0., tv_.format); break;
case 7: clen = printValue(ptr != 0 ? *(const short*)ptr : short(0), tv_.format); break;
case 8: clen = printValue(ptr != 0 ? *(const uint*)ptr : 0u, tv_.format); break;
case 9: clen = printValue(ptr != 0 ? *(const ulong*)ptr : 0ul, tv_.format); break;
case 10: clen = printValue(ptr != 0 ? *(const ushort*)ptr : ushort(0), tv_.format); break;
case 11: clen = printValue(ptr != 0 ? *(const uchar*)ptr : uchar(0), tv_.format); break;
case 12: clen = printValue(ptr != 0 ? *(const llong*)ptr : 0l, tv_.format); break;
case 13: clen = printValue(ptr != 0 ? *(const ullong*)ptr: 0ull, tv_.format); break;
case 20: clen = printValue(ptr != 0 ? *(const PISystemTime*)ptr: PISystemTime(), tv_.format); break;
case 14: clen = printValue(bitsValue(ptr, tv_.bitFrom, tv_.bitCount), tv_.format); break;
}
if (clen + tv.offset < (uint)col_wid) {
if (clen + tv_.offset < (uint)col_wid) {
PIString ts = PIString(
#if defined(QNX) || defined(FREE_BSD)
col_wid - clen - tv.offset - 1, ' ');
col_wid - clen - tv_.offset - 1, ' ');
#else
col_wid - clen - tv.offset, ' ');
col_wid - clen - tv_.offset, ' ');
#endif
printf("%s", ts.data());
}
@@ -575,10 +575,10 @@ void PIConsole::fillLabels() {
if (int(j) > height - 3) continue;
if (max_y < j) max_y = j;
moveRight(cx);
Variable & tv(cvars[j]);
Variable & tv_(cvars[j]);
cvars[j].nx = cx;
cvars[j].ny = cy;
if (tv.name.isEmpty()) {
if (tv_.name.isEmpty()) {
cvars[j].offset = 0;
clearLine();
newLine();
@@ -586,33 +586,33 @@ void PIConsole::fillLabels() {
continue;
}
clearLine();
//piCout << tv.name << tv.type << tv.ptr;
if (tv.type == 15) {
//piCout << tv_.name << tv_.type << tv_.ptr;
if (tv_.type == 15) {
cvars[j].offset = cvars[j].name.length();
cvars[j].nx += cvars[j].offset;
printLine(tv.name, cx, tv.format);
printLine(tv_.name, cx, tv_.format);
newLine();
cy++;
continue;
}
if (!tv.isEmpty()) {
if (!tv_.isEmpty()) {
switch (ccol.alignment) {
case Nothing:
cvars[j].offset = (tv.name + ": ").length();
cvars[j].offset = (tv_.name + ": ").length();
cvars[j].nx += cvars[j].offset;
printValue(tv.name + ": ", tv.format);
printValue(tv_.name + ": ", tv_.format);
break;
case Left:
cvars[j].offset = mx;
cvars[j].nx += cvars[j].offset;
printValue(tv.name + ": ", tv.format);
printValue(tv_.name + ": ", tv_.format);
break;
case Right:
cvars[j].offset = mx;
cvars[j].nx += cvars[j].offset;
dx = mx - (tv.name + ": ").length();
dx = mx - (tv_.name + ": ").length();
moveRight(dx);
printValue(tv.name + ": ", tv.format);
printValue(tv_.name + ": ", tv_.format);
moveLeft(dx);
break;
}

View File

@@ -336,6 +336,8 @@ private:
struct Variable {
Variable() {nx = ny = type = offset = bitFrom = bitCount = size = 0; format = Normal; remote = false; ptr = 0; id = 1;}
Variable(const Variable & src) {remote = src.remote; name = src.name; format = src.format; type = src.type; offset = src.offset; size = src.size;
bitFrom = src.bitFrom; bitCount = src.bitCount; ptr = src.ptr; nx = src.nx; ny = src.ny; rdata = src.rdata; id = src.id;}
bool isEmpty() const {return (remote ? false : ptr == 0);}
const void * data() {return (remote ? rdata.data() : ptr);}
void writeData(PIByteArray & ba) {

View File

@@ -131,7 +131,7 @@ PRIVATE_DEFINITION_START(PIKbdListener)
PRIVATE_DEFINITION_END(PIKbdListener)
PIKbdListener::PIKbdListener(KBFunc slot, void * _data, bool startNow): PIThread() {
PIKbdListener::PIKbdListener(KBFunc slot, void * _d, bool startNow): PIThread() {
setName("keyboard_listener");
_object = this;
#ifdef WINDOWS
@@ -142,7 +142,7 @@ PIKbdListener::PIKbdListener(KBFunc slot, void * _data, bool startNow): PIThread
#endif
is_active = true;
ret_func = slot;
data_ = _data;
kbddata_ = _d;
PIKbdListener::exiting = exit_enabled = false;
if (startNow) start();
}
@@ -317,8 +317,8 @@ void PIKbdListener::readKeyboard() {
return;
}
if (ret > 0) {
keyPressed(ke, data_);
if (ret_func != 0) ret_func(ke, data_);
keyPressed(ke, kbddata_);
if (ret_func != 0) ret_func(ke, kbddata_);
}
}

View File

@@ -97,10 +97,10 @@ public:
//! Returns custom data
void * data() {return data_;}
void * data() {return kbddata_;}
//! Set custom data to "_data"
void setData(void * _data) {data_ = _data;}
void setData(void * _data) {kbddata_ = _data;}
//! Set external function to "slot"
void setSlot(KBFunc slot) {ret_func = slot;}
@@ -185,7 +185,7 @@ private:
KBFunc ret_func;
int exit_key;
bool exit_enabled, is_active;
void * data_;
void * kbddata_;
char rc[8];
KeyEvent ke;
static PIKbdListener * _object;