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

@@ -170,6 +170,7 @@ void PICodeParser::clear() {
cur_namespace.clear();
main_file.clear();
evaluator.clearCustomVariables();
cur_def_vis = Global;
defines << Define("PICODE", "") << custom_defines;
}

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;

View File

@@ -419,7 +419,9 @@ private:
if (as != pid_rsize) {
//printf("(%p) realloc %d -> %d (%p)\n", this, pid_rsize, as, pid_data);
PIINTROSPECTION_CONTAINER_ALLOC((as-pid_rsize)*sizeof(T))
pid_data = (T*)(realloc(pid_data, as*sizeof(T)));
T * p_d = (T*)(realloc(pid_data, as*sizeof(T)));
if (p_d)
pid_data = p_d;
pid_rsize = as;
//printf("(%p) realloc done (%p)\n", this, pid_data);
}

View File

@@ -356,7 +356,9 @@ private:
if (as == piv_rsize) return;
//cout << std::hex << " ![("<<this<<")realloc " << piv_data << " data ... <\n" << endl;
piv_data = (T*)(realloc(piv_data, as*sizeof(T)));
T * p_d = (T*)(realloc(piv_data, as*sizeof(T)));
if (p_d)
piv_data = p_d;
//zeroRaw(&(piv_data[os]), as - os);
piv_rsize = as;
//cout << std::hex << " > (new 0x" << (llong)piv_data << ") ok]!" << endl;

View File

@@ -55,7 +55,8 @@ public:
public:
//! Constructs data block
RawData(void * data = 0, int size = 0) {d = data; s = size;}
//! Constructs data block
RawData(const RawData & o) {d = o.d; s = o.s;}
//! Constructs data block
RawData(const void * data, const int size) {d = const_cast<void * >(data); s = size;}
RawData & operator =(const RawData & o) {d = o.d; s = o.s; return *this;}
private:

View File

@@ -190,7 +190,7 @@ PICout PICout::operator <<(const PICoutAction v) {
#define PINUMERICCOUT if (cnb_ == 10) PICOUTTOTARGET(v) else PICOUTTOTARGET(PIString::fromNumber(v, cnb_))
PICout PICout::operator <<(const char * v) {if (v == '\0') return *this; space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}
PICout PICout::operator <<(const char * v) {if (v[0] == '\0') return *this; space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}
PICout PICout::operator <<(const std::string & v) {space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}

View File

@@ -87,7 +87,7 @@ public:
//! %Rule of transition between states of machine
struct Rule {
//! Constuctor
Rule() {handler = 0;}
Rule() {handler = 0; from = to = Type(); autoTransition = resetAllConditions = false;}
//! Constuctor
Rule(Type f, Type t, const PIStringList & c = PIStringList(), Handler h = 0, bool at = false, bool rac = false) {
from = f;
@@ -119,7 +119,7 @@ public:
//! %State of machine
struct State {
//! Constuctor
State() {handler = 0;}
State() {handler = 0; value = Type();}
//! Constuctor
State(Type v, const PIString & n = "", Handler h = 0) {value = v; name = n; handler = h;}
//! %State value

View File

@@ -54,7 +54,17 @@ PIMap<PIString, __PIVariantInfo__ * > * __PIVariantInfoStorage__::map = 0;
PIVariant::PIVariant() {
_type = PIVariant::pivInvalid;
_type = PIVariant::pivInvalid;
_info = 0;
}
PIVariant::PIVariant(const PIVariant &v) {
_type = v._type;
_content = v._content;
#ifdef CUSTOM_PIVARIANT
_info = v._info;
#endif
}

View File

@@ -162,6 +162,8 @@ public:
//! Empty constructor, \a type() will be set to \a Invalid
PIVariant();
PIVariant(const PIVariant & v);
//! Constructs variant from string
PIVariant(const char * v) {initType(PIString(v));}

View File

@@ -110,7 +110,7 @@ public:
friend class PIConfig;
friend class Branch;
public:
Entry() {_parent = 0;}
Entry() {_parent = 0; _line = -1;}
//! Returns parent entry, or 0 if there is no parent (root of default value)
Entry * parent() const {return _parent;}

View File

@@ -122,12 +122,14 @@ PIString PIFile::FileInfo::dir() const {
PIFile::PIFile(): PIIODevice() {
fd = 0;
fdi = -1;
setPrecision(5);
}
PIFile::PIFile(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(path, mode) {
fd = 0;
fdi = -1;
setPrecision(5);
if (!path.isEmpty())
@@ -136,7 +138,8 @@ PIFile::PIFile(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(p
PIFile::PIFile(const PIFile & other) {
fdi = -1;
fd = 0;
fdi = -1;
setPrecision(other.prec_);
setPath(other.path());
mode_ = other.mode_;

View File

@@ -170,7 +170,6 @@ private:
PIByteArray buffer, tmpbuf, src_header, src_footer, trbuf;
PacketExtractorCheckFunc ret_func_header, ret_func_footer;
SplitMode mode_;
void * data;
int buffer_size, dataSize, packetSize_hf, footerInd, packetSize_;
double time_;
bool header_found;

View File

@@ -27,8 +27,6 @@ PIUSB::PIUSB(ushort vid, ushort pid): PIIODevice("", ReadWrite) {
void PIUSB::Endpoint::parse() {
direction = Write;
transfer_type = Control;
synchronisation_type = NoSynchonisation;
usage_type = DataEndpoint;
direction = (Direction)((address >> 7) & 1);

View File

@@ -775,7 +775,6 @@ int PIEvaluator::parse(const PIString & string, int offset) {
bcnt = farg = 1;
///qDebug() << "function: " + cfunc.identifier;
//for (int k = 0; k < facnt; k++) {
bcnt = 1;
carg = "";
k = i + 1;
//if (string.size_s() <= k || k < 0) return -666;

View File

@@ -49,7 +49,7 @@ namespace PIEvaluatorTypes {
};
struct Instruction {
Instruction() {;}
Instruction() {out = -1; function = -1; operation = oNone;}
Instruction(Operation oper, PIVector<int> opers, int out_ind, int func = -1) {
operation = oper; operators = opers; out = out_ind; function = func;}
Operation operation;
@@ -58,7 +58,7 @@ namespace PIEvaluatorTypes {
int function;
};
struct Element {
Element() {;}
Element() {num = 0; var_num = -1; type = etNumber;}
Element(eType new_type, int new_num, int new_var_num = -1) {set(new_type, new_num, new_var_num);}
void set(eType new_type, int new_num, int new_var_num = -1) {type = new_type; num = new_num; var_num = new_var_num;}
eType type;

View File

@@ -41,7 +41,7 @@ public:
fp & operator =(const float &v) {val = PIFixedPoint(v).val; return *this;}
fp & operator =(const double &v) {val = PIFixedPoint(v).val; return *this;}
fp & operator =(const long double &v) {val = PIFixedPoint(v).val; return *this;}
fp & operator -() {fp p = fp(*this); p.val = -val; return p;}
fp operator -() {fp p = fp(*this); p.val = -val; return p;}
bool operator ==(const fp & v) const {return val == v.val;}
bool operator !=(const fp & v) const {return val != v.val;}

View File

@@ -39,6 +39,7 @@ PIProcess::PIProcess(): PIThread() {
is_exec = false;
g_in = g_out = g_err = false;
t_in = t_out = t_err = false;
tf_in = tf_out = tf_err = 0;
env = PIProcess::currentEnvironment();
}
@@ -180,7 +181,7 @@ void PIProcess::startProc(bool detached) {
is_exec = false;
for (int i = 0; i < env.size_s(); ++i)
delete e[i];
delete e;
delete[] e;
#ifdef WINDOWS
delete a;
#else

View File

@@ -331,7 +331,7 @@ int main(int argc, char * argv[]) {
piDebug = true;
PIStringList pf(parser.parsedFiles());
piForeachC (PIString & f, pf) {
if ((womain && (f != parser.mainFile())) || !womain)
if (!womain || (f != parser.mainFile()))
piCout << f;
}
}