{"id":216157,"date":"2014-03-18T09:02:03","date_gmt":"2014-03-18T05:02:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=216157"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=216157","title":{"rendered":"<span class=\"post_title\">\u0415\u0434\u0438\u043d\u043e\u0440\u043e\u0433 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0441\u044f \u043c\u0438\u043a\u0440\u043e\u043c\u0438\u0440\u043e\u043c<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/2b1\/578\/3f2\/2b15783f2f481b823c3b50bcadaca205.png\" alt=\"PVS-Studio and \u03bcManager (Micro-Manager)\" align=\"left\"\/><br \/>  \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0430\u043c \u043f\u0440\u0435\u043f\u043e\u0434\u043d\u0451\u0441 \u043c\u0438\u043a\u0440\u043e\u043c\u0438\u0440. \u041c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u043a\u043e\u0434\u0430 PVS-Studio \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u03bcManager. \u042d\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043c\u0438\u043a\u0440\u043e\u0441\u043a\u043e\u043f\u0430.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u03bcManager<\/h2>\n<p>  \u042d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u041e\u0431\u044a\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043e\u043a\u043e\u043b\u043e 11 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442. \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u0435\u043d \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442, \u044f \u043d\u0435 \u0437\u043d\u0430\u044e. \u041c\u0435\u043d\u044f \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b\u0438 \u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c. \u0418 \u0432\u043e\u0442 \u0435\u0434\u0438\u043d\u043e\u0440\u043e\u0433 \u0443\u0436\u0435 \u0441\u043f\u0435\u0448\u0438\u0442 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043d\u0443\u0436\u043d\u044b\u0439 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0440\u0430\u0437 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b\u0438.<\/p>\n<p>  \u0421\u0430\u0439\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: <a href=\"http:\/\/www.micro-manager.org\/\">Micro-Manager<\/a>.<\/p>\n<p>  \u0410\u043d\u0430\u043b\u0438\u0437 \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 <a href=\"http:\/\/www.viva64.com\/en\/pvs-studio\/\">PVS-Studio<\/a>. \u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438, \u0442\u043e \u0432\u043e\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0442\u0430\u043a \u0434\u043e\u043b\u0433\u043e \u0436\u0434\u0430\u043b\u0438 \u043d\u0430\u0448\u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438: &quot;<a href=\"http:\/\/www.viva64.com\/ru\/b\/0241\/\">\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432 \u043a\u043e\u0434\u0430: CppCat, Cppcheck, PVS-Studio, Visual Studio<\/a>&quot;.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043b\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u043e\u043a\u043e\u043d\u0447\u0435\u043d\u043e. \u041d\u0430\u0447\u043d\u0451\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430.<\/p>\n<h2>long != int<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/2e1\/a9e\/f58\/2e1a9ef5869d1f3e9060271faddda42c.png\" alt=\"long!=int\" \/><\/div>\n<p>  \u041f\u0440\u043e\u0435\u043a\u0442 \u03bcManager \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442 \u043d\u0430 \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043d\u0430\u0434\u043e \u0431\u044b\u0442\u044c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b\u043c \u0441 \u0442\u0438\u043f\u043e\u043c &#8216;long&#8217;. \u0412 32-\u0431\u0438\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0438\u043f\u0430 &#8216;long&#8217; \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0442\u0438\u043f\u0430 &#8216;int&#8217;. \u0410 \u0432\u043e\u0442 \u0432 64-\u0431\u0438\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u0412 Win64 \u0442\u0438\u043f &#8216;long&#8217; \u043e\u0441\u0442\u0430\u043b\u0441\u044f 32-\u0431\u0438\u0442\u043d\u044b\u043c. \u0412 64-\u0431\u0438\u0442\u043d\u043e\u043c \u043c\u0438\u0440\u0435 Linux \u043f\u0440\u0438\u043d\u044f\u0442\u0430 \u0434\u0440\u0443\u0433\u0430\u044f <a href=\"http:\/\/www.viva64.com\/ru\/t\/0012\/\">\u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 &#8216;long&#8217; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f 64-\u0431\u0438\u0442\u043d\u044b\u043c. \u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0442\u044c \u0431\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u043e\u0442 \u0442\u0438\u043f.<\/p>\n<p>  \u041f\u0440\u043e\u0435\u043a\u0442 \u03bcManager \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0439 \u043a\u043e\u0434:  <\/p>\n<pre><code class=\"cpp\">typedef struct _DCMOTSTATUS {   unsigned short wChannel;   \/\/ Channel ident.   unsigned int lPosition;    \/\/ Position in encoder counts.    unsigned short wVelocity;  \/\/ Velocity in encoder counts\/sec.   unsigned short wReserved;  \/\/ Controller specific use    unsigned int dwStatusBits; \/\/ Status bits (see #defines below). } DCMOTSTATUS;  int MotorStage::ParseStatus(...., DCMOTSTATUS&amp; stat) {   ....   memcpy(&amp;stat.lPosition, buf + bufPtr, sizeof(long));  \/\/&lt;&lt;&lt;(1)   bufPtr += sizeof(long);    memcpy(&amp;stat.wVelocity, buf + bufPtr, sizeof(unsigned short));   bufPtr += sizeof(unsigned short);    memcpy(&amp;stat.wReserved, buf + bufPtr, sizeof(unsigned short));   bufPtr += sizeof(unsigned short);    memcpy(&amp;stat.dwStatusBits,          buf + bufPtr, sizeof(unsigned long));          \/\/&lt;&lt;&lt;(2)   return DEVICE_OK; }<\/code><\/pre>\n<p>  \u0412 \u0441\u0442\u0440\u043e\u043a\u0435 (1) \u0438 (2) \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u0442\u0438\u043f &#8216;int&#8217;. \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442, \u0440\u0430\u0432\u043d\u043e\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0442\u0438\u043f\u0430 &#8216;long&#8217;. \u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0432 64-\u0431\u0438\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 &#8216;long&#8217; \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c 8 \u0431\u0430\u0439\u0442. \u0410 \u0442\u0438\u043f &#8216;int&#8217; \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 4 \u0431\u0430\u0439\u0442\u0430.<\/p>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 (1) \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e. \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0414\u0430\u043b\u044c\u0448\u0435 \u044d\u0442\u0438 \u0447\u043b\u0435\u043d\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u0435\u0449\u0451 \u0440\u0430\u0437. \u0423\u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u0410 \u0432\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 (2) \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u043d. \u0418\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0447\u043b\u0435\u043d\u0430. \u041f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0437\u0430 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0435\u0437\u0435\u043d\u0438\u044f \u0438 \u0444\u0430\u0437\u044b \u043b\u0443\u043d\u044b.<\/p>\n<p>  \u041e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c PVS-Studio:<\/p>\n<ul>\n<li>V512 A call of the &#8216;memcpy&#8217; function will lead to overflow of the buffer &#8216;&amp; stat.lPosition&#8217;. MotorStage.cpp 247<\/li>\n<li>V512 A call of the &#8216;memcpy&#8217; function will lead to overflow of the buffer &#8216;&amp; stat.dwStatusBits&#8217;. MotorStage.cpp 256<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438 \u0443\u043f\u043b\u043e\u0442\u043d\u0438\u0442\u0435\u043b\u044c \u043c\u0443\u0441\u043e\u0440\u0430!<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/2fe\/539\/c72\/2fe539c727a96dfd4b9a3a5e2f913e04.png\" alt=\"R2D2, stop the Garbage Compactor 3263827\" \/><\/div>\n<p>  <\/p>\n<pre><code class=\"cpp\">const unsigned char stopSgn[2] = {0x04, 0x66}; int MotorStage::Stop() {   ....   if (memcmp(stopSgn, answer, sizeof(stopSgn) != 0))     return ERR_UNRECOGNIZED_ANSWER;   .... }<\/code><\/pre>\n<p>  \u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f memcmp() \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0431\u0430\u0439\u0442. \u041f\u043e\u0447\u0435\u043c\u0443? \u041e\u0431\u0438\u0434\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430. \u041d\u0435 \u0442\u0430\u043c \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0430\u044f\u0441\u044f \u0441\u043a\u043e\u0431\u043a\u0430. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a: sizeof(stopSgn) != 0. \u042d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e &#8216;true&#8217;, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443.<\/p>\n<p>  \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c:  <\/p>\n<pre><code class=\"cpp\">if (memcmp(stopSgn, answer, sizeof(stopSgn)) != 0)<\/code><\/pre>\n<p>  \u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438: V526 The &#8216;memcmp&#8217; function returns 0 if corresponding buffers are equal. Consider examining the condition for mistakes. MotorStage.cpp 385<\/p>\n<h2>\u0418\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/0bc\/c42\/ead\/0bcc42ead0006c252c1df995a15a00d4.png\" alt=\"Identical comparisons\" \/><\/div>\n<p>  <\/p>\n<pre><code class=\"cpp\">const char* g_Out = &quot;Out&quot;; int FieldDiaphragm::OnCondensor(....) {   ....   std::string value;   ....   if (value == g_Out)     return       g_hub.SetCondensorPosition(*this, *GetCoreCallback(), 0);   else if (value == g_Out)     return       g_hub.SetCondensorPosition(*this, *GetCoreCallback(), 1);   .... }<\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;if&#8217; \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435. \u041a\u0430\u043a\u0438\u043c \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u044f \u043d\u0435 \u0437\u043d\u0430\u044e. \u041e\u0434\u043d\u0430\u043a\u043e, \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u0414\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430, \u0432\u044b\u044f\u0432\u0438\u0432\u0448\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0443: V517 The use of &#8216;if (A) {&#8230;} else if (A) {&#8230;}&#8217; pattern was detected. There is a probability of logical error presence. Check lines: 1455, 1457. LeicaDMR.cpp 1455<\/p>\n<p>  \u0415\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u0412\u0438\u0434\u0438\u043c\u043e, \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043a\u043e\u043b\u0451\u0441\u0438\u043a\u0430 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:  <\/p>\n<pre><code class=\"cpp\">class Wheel : public CStateDeviceBase&lt;Wheel&gt; {   ....   unsigned wheelNumber_;   .... };  int Wheel::SetWheelPosition(int position) {   unsigned char cmd[4];   cmd[0] = moduleId_; cmd[2] = 0; cmd[3] = 58;   if (wheelNumber_ == 1) {     switch (position) {       case 0: cmd[1] = 49; break;       case 1: cmd[1] = 50; break;       case 2: cmd[1] = 51; break;       case 3: cmd[1] = 52; break;       case 4: cmd[1] = 53; break;       case 5: cmd[1] = 54; break;     }   } else if (wheelNumber_ == 1) {     switch (position) {       case 0: cmd[1] = 33; break;       case 1: cmd[1] = 64; break;       case 2: cmd[1] = 35; break;       case 3: cmd[1] = 36; break;       case 4: cmd[1] = 37; break;       case 5: cmd[1] = 94; break;     }   .... }<\/code><\/pre>\n<p>  \u0414\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 PVS-Studio: V517 The use of &#8216;if (A) {&#8230;} else if (A) {&#8230;}&#8217; pattern was detected. There is a probability of logical error presence. Check lines: 645, 654. Ludl.cpp 645<\/p>\n<h2>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u043c\u044b \u043e \u0447\u0451\u043c-\u0442\u043e \u0437\u0430\u0431\u044b\u043b\u0438<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/fff\/0b4\/dd3\/fff0b4dd3fd434af8eda9ed4c6d4da67.png\" alt=\"Feel like we&#39;ve missed something\" \/><\/div>\n<p>  \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u043e\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434. \u0417\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0435\u0433\u043e \u0432 \u043d\u0451\u043c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442?  <\/p>\n<pre><code class=\"cpp\">class MP285 {   ....   static int GetMotionMode() { return m_nMotionMode; }   .... };  int ZStage::_SetPositionSteps(....) {   ....   if (MP285::GetMotionMode == 0)   {     long lOldZPosSteps = (long)MP285::Instance()-&gt;GetPositionZ();     dSec = (double)labs(lZPosSteps-lOldZPosSteps) \/ dVelocity;   }   else   {      dSec = (double)labs(lZPosSteps) \/ dVelocity;   }   .... }<\/code><\/pre>\n<p>  \u041d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e\u0439 \u0432\u0435\u0449\u0438. \u0417\u0430\u0431\u044b\u0442\u044b \u0441\u043a\u043e\u0431\u043e\u0447\u043a\u0438 (). \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e GetMotionMode() \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043d\u0443\u043b\u0451\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0441 \u043d\u0443\u043b\u0451\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u041e\u0448\u0438\u0431\u043a\u0430 \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438: V516 Consider inspecting an odd expression. Non-null function pointer is compared to null: &#8216;MP285::GetMotionMode == 0&#8217;. MP285ZStage.cpp 558<\/p>\n<h2>\u041e\u0434\u0438\u043d\u043e\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u043d\u0438\u043a<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/e6f\/678\/fd5\/e6f678fd51a622bae68db9bb0ae30470.png\" alt=\"wanderer\" \/><\/div>\n<p>  <\/p>\n<pre><code class=\"cpp\">int HalogenLamp::SetIntensity(long intensity) {   ....   command_stream.str().c_str();   .... }<\/code><\/pre>\n<p>  \u0427\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435? \u041f\u043e\u0431\u043e\u0447\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430? \u041d\u0435\u0434\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434? \u0411\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u0430\u044f \u043b\u0438\u0448\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430?<\/p>\n<p>  \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0442\u0430\u043a\u0438\u0445 \u043e\u0434\u0438\u043d\u043e\u043a\u0438\u0445 \u0441\u0442\u0440\u0430\u043d\u043d\u0438\u043a\u043e\u0432:<\/p>\n<ul>\n<li>V530 The return value of function &#8216;c_str&#8217; is required to be utilized. ZeissCAN.cpp 1553<\/li>\n<li>V530 The return value of function &#8216;c_str&#8217; is required to be utilized. ZeissCAN.cpp 2800<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u00ab\u0411\u0440\u0430\u043c\u0438\u043d\u044b\u00bb<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/c32\/702\/828\/c327028283a01e47d18cc37bf1d5d0d7.png\" alt=\"Brahmins\" \/><\/div>\n<p>  <\/p>\n<pre><code class=\"cpp\">int LeicaScopeInterface::GetDICTurretInfo(....) {   ....   std::string tmp;   ....   if (tmp == &quot;DIC-TURRET&quot;)     scopeModel_-&gt;dicTurret_.SetMotorized(true);   else     scopeModel_-&gt;dicTurret_.SetMotorized(true);   .... }<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 &quot;<a href=\"http:\/\/www.viva64.com\/go.php?url=1365\">\u0431\u0440\u0430\u043c\u0438\u043d<\/a>&quot;. \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0438\u043b\u0438 \u043d\u0435\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435: V523 The &#8216;then&#8217; statement is equivalent to the &#8216;else&#8217; statement. LeicaDMIScopeInterface.cpp 1296<\/p>\n<p>  \u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0441\u0445\u043e\u0436\u0435\u0433\u043e \u0440\u043e\u0434\u0430. \u0417\u0434\u0435\u0441\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0443:  <\/p>\n<pre><code class=\"cpp\">int XLedDev::Initialize() {   ....   if (strcmp(     XLed::Instance()-&gt;GetXLedStr(XLed::XL_WLedDevName +                                  m_nLedDevNumber).c_str(),     XLed::Instance()-&gt;GetXLedStr(XLed::XL_WLedDevName +                                  m_nLedDevNumber).c_str()             ) != 0)   .... }<\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435: V549 The first argument of &#8216;strcmp&#8217; function is equal to the second argument. XLedDev.cpp 119<\/p>\n<h2>\u0427\u0442\u043e-\u0442\u043e \u043d\u0435 \u0441\u0442\u044b\u043a\u0443\u0435\u0442\u0441\u044f<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/18b\/bd3\/272\/18bbd32724005d628f89092f157a876d.png\" alt=\"A mismatch\" \/><\/div>\n<p>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f &#8216;false&#8217; \u0438 &#8216;true&#8217; \u043c\u043e\u0433\u0443\u0442 \u043d\u0435\u044f\u0432\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043a \u0442\u0438\u043f\u0443 &#8216;int&#8217;:<\/p>\n<ul>\n<li>false \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 0;<\/li>\n<li>true \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 1.<\/li>\n<\/ul>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f:  <\/p>\n<pre><code class=\"cpp\">int F() { return false; }<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f F() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 0.<\/p>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u043b\u044e\u0434\u0438 \u043e\u0448\u0438\u0431\u0430\u044e\u0442\u0441\u044f \u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f &#8216;int&#8217;, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 &#8216;false&#8217; \u0438\u043b\u0438 &#8216;true&#8217;. \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e \u043f\u043e \u0437\u0430\u0431\u044b\u0432\u0447\u0438\u0432\u043e\u0441\u0442\u0438. \u041d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u0443\u0441 \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c 0.<\/p>\n<p>  \u0411\u0435\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u044b \u043e\u0448\u0438\u0431\u043e\u043a \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043e\u0442 \u043d\u0443\u043b\u044f. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u03bcManager.<\/p>\n<p>  \u0418\u043c\u0435\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:  <\/p>\n<pre><code class=\"cpp\">#define DEVICE_OK   0 #define DEVICE_ERR  1 \/\/ generic, undefined error #define DEVICE_INVALID_PROPERTY  2 #define DEVICE_INVALID_PROPERTY_VALUE  3 #define DEVICE_INVALID_PROPERTY_TYPE   5 ....<\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e 0 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e. \u0414\u0440\u0443\u0433\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0442 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>  \u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u03bcManager \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u0430 \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0430\u043c\u0438 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 &#8216;true&#8217;, &#8216;false&#8217;.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e CreateProperty():  <\/p>\n<pre><code class=\"cpp\">int MM::PropertyCollection::CreateProperty(....) {   if (Find(pszName))     return DEVICE_DUPLICATE_PROPERTY;   ....   if (!pProp-&gt;Set(pszValue))     return false;   ....   return DEVICE_OK; }<\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b\u0437\u043e\u0432 pProp-&gt;Set(pszValue) \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0441\u044f \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 &#8216;false&#8217;. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 DEVICE_OK. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u043e.<\/p>\n<p>  \u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430:  <\/p>\n<pre><code class=\"cpp\">int MM::PropertyCollection::RegisterAction(   const char* pszName, MM::ActionFunctor* fpAct) {   MM::Property* pProp = Find(pszName);   if (!pProp)     return DEVICE_INVALID_PROPERTY;   pProp-&gt;RegisterAction(fpAct);   return true; }<\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u00abreturn true;\u00bb. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0451\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 DEVICE_ERR 1 (generic, undefined error). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e.<\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u044f \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u044d\u0442\u0438 \u043c\u0435\u0441\u0442\u0430 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u0430 \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0438. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u0435\u0441\u0442\u0430\u043c\u0438 &#8216;false&#8217; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0441\u043e\u0431\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438. \u041f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"cpp\">int XYStage::Home() {   ....   if (ret != DEVICE_OK)   {     ostringstream os;     os &lt;&lt; &quot;ReadFromComPort failed in &quot;           &quot;XYStage::Busy, error code:&quot; &lt;&lt; ret;     this-&gt;LogMessage(os.str().c_str(), false);     return false; \/\/ Error, let's pretend all is fine   }   .... }<\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439. \u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430. \u041d\u043e \u043c\u044b \u043f\u0440\u0438\u0442\u0432\u043e\u0440\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e, \u0432\u0435\u0440\u043d\u0443\u0432 \u043d\u043e\u043b\u044c. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, &#8216;false&#8217; \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0432\u043c\u0435\u0441\u0442\u043e DEVICE_OK, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043f\u0440\u0430\u0432\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u043e\u0447\u043a\u0430. \u0410 \u0432\u043e\u0442 \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043e\u0448\u0438\u0431\u043a\u0430 \u044d\u0442\u043e \u0438\u043b\u0438 \u00ab\u0445\u0438\u0442\u0440\u044b\u0439 \u0444\u0438\u043d\u0442 \u0443\u0448\u0430\u043c\u0438\u00bb. \u0420\u0438\u0441\u043a\u043d\u0443 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435 \u043c\u0435\u0441\u0442 \u0432\u0441\u0451 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0430 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/98d\/849\/f0b\/98d849f0b58b3c5c3b15186bd5e885a0.png\" alt=\"Smells\" \/><\/div>\n<p>  \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u043f\u043b\u043e\u0445\u043e \u043f\u0430\u0445\u043d\u0435\u0442. <\/p>\n<p>  \u0412\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0441\u0442:<\/p>\n<ul>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. Property.cpp 364<\/li>\n<li>V601 The &#8216;true&#8217; value is implicitly casted to the integer type. Property.cpp 464<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. PIGCSControllerCom.cpp 405<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. Prior.cpp 778<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. Prior.cpp 2308<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. Prior.cpp 2313<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. Prior.cpp 2322<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. SutterLambda.cpp 190<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. SutterLambda.cpp 269<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. SutterLambda.cpp 285<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. Tofra.cpp 900<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. Tofra.cpp 1806<\/li>\n<li>V601 The &#8216;false&#8217; value is implicitly casted to the integer type. Tofra.cpp 1830<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0421\u0442\u0440\u0430\u043d\u043d\u044b\u0439 Get<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/ae4\/b6c\/519\/ae4b6c51932cc34d7510155fe0bbaa77.png\" alt=\"Strange\" \/><\/div>\n<p>  <\/p>\n<pre><code class=\"cpp\">int pgFocus::GetOffset(double&amp; offset) {   MM_THREAD_GUARD_LOCK(&amp;mutex);   deviceInfo_.offset = offset;   MM_THREAD_GUARD_UNLOCK(&amp;mutex);   return DEVICE_OK; }<\/code><\/pre>\n<p>  \u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0438\u043b\u0438 \u0441 \u044d\u0442\u0438 \u043a\u043e\u0434\u043e\u043c \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435?<\/p>\n<p>  \u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0443 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f: V669 The &#8216;offset&#8217; argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. pgFocus.cpp 356<\/p>\n<p>  \u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0441\u0442\u0440\u0430\u043d\u043d\u043e. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u00abGet____\u00bb. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441. \u0410 \u0435\u0449\u0451 \u043e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 &#8216;offset&#8217; \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435. \u0418\u2026 \u0418 \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0432 \u043d\u0435\u0433\u043e. \u042f \u043d\u0435 \u0437\u043d\u0430\u044e, \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e, \u0431\u044b\u0442\u044c \u043c\u043e\u0436\u0435\u0442, \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442? \u041a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">offset = deviceInfo_.offset;<\/code><\/pre>\n<p>  \u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f GetTransmission():  <\/p>\n<pre><code class=\"cpp\">int SpectralLMM5Interface::GetTransmission(....,                                            double&amp; transmission) {   ....   int16_t tr = 0;   memcpy(&amp;tr, answer + 1, 2);   tr = ntohs(tr);   transmission = tr\/10;   .... }<\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio: V636 The &#8216;tr \/ 10&#8217; expression was implicitly casted from &#8216;int&#8217; type to &#8216;double&#8217; type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) \/ Y;. SpectralLMM5Interface.cpp 198<\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f double (\u0440\u0435\u0447\u044c \u0438\u0434\u0451\u0442 \u043e transmission). \u041d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u043e. \u0426\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 10. \u0423 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u0435\u0440\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 &#8216;tr&#8217; \u0440\u0430\u0432\u043d\u043e 5, \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c 0, \u0430 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 0.5.<\/p>\n<p>  \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">transmission = tr\/10.0;<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041e\u0448\u0438\u0431\u043a\u0430 \u0438\u043b\u0438 \u043d\u0435 \u043e\u0448\u0438\u0431\u043a\u0430? \u041f\u0435\u0440\u0432\u043e\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u043c\u0430\u043d\u0447\u0438\u0432\u043e.<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/184\/bdf\/8e0\/184bdf8e023a42e18b5692f1e607c34a.png\" alt=\"Error or not?\" \/><\/div>\n<p>  \u0412 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438\/\u0421\u0438++, \u0447\u0438\u0441\u043b\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 \u043d\u0443\u043b\u044f \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u0438\u0447\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u03bcManager \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e:  <\/p>\n<pre><code class=\"cpp\">int LeicaDMSTCHub::StopXY(MM::Device&amp; device, MM::Core&amp; core) {   int ret = SetCommand(device, core, xyStage_, 010);      if (ret != DEVICE_OK)     return ret;   return DEVICE_OK; }<\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio: V536 Be advised that the utilized constant value is represented by an octal form. Oct: 010, Dec: 8. LeicaDMSTCHub.cpp 142<\/p>\n<p>  \u041d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e 8, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u0438\u0447\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0438\u043b\u0438 \u044d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430. \u0412 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e SetCommand() \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u0430, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">int ret = SetCommand(device, core, xyStage_, 35, ack);<\/code><\/pre>\n<p>  \u041d\u0435 \u0437\u043d\u0430\u044e, \u043d\u0430\u0439\u0434\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u043b\u0438 \u043d\u0435\u0442, \u043d\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043f\u0440\u043e \u044d\u0442\u043e \u043c\u0435\u0441\u0442\u043e \u0441\u0442\u043e\u0438\u0442.<\/p>\n<h3>\u041f\u0435\u0440\u0444\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0441\u0442 \u043d\u0435\u0433\u043e\u0434\u0443\u0435\u0442<\/h3>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/1d4\/266\/7c7\/1d42667c7e353a21ddc1305838af0046.png\" alt=\"Perfectionist\" \/><\/div>\n<p>  \u0415\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0430 \u043c\u0435\u043b\u043e\u0447\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u043f\u0435\u0440\u0444\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0441\u0442\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0432\u043e\u0440\u0447\u0438\u043c.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u0442\u0440\u043e\u0447\u0435\u043a. \u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:  <\/p>\n<pre><code class=\"cpp\">int XYStage::OnTriggerEndX(MM::PropertyBase* pProp,                            MM::ActionType eAct){     if (eAct == MM::BeforeGet)   {       int ret = GetCommandValue(&quot;trgse&quot;,xChannel_,chx_.trgse_);     if (ret!=DEVICE_OK)     if (ret!=DEVICE_OK)       return ret;         ..... }<\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044f\u0432\u043d\u043e \u043b\u0438\u0448\u043d\u044f\u044f. <\/p>\n<p>  \u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"cpp\">int AFC::Initialize()  {   int ret = DEVICE_OK;   ....   if (ret != DEVICE_OK)     return ret;   AddAllowedValue(&quot;DichroicMirrorIn&quot;, &quot;0&quot;, 0);   AddAllowedValue(&quot;DichroicMirrorIn&quot;, &quot;1&quot;, 1);   if (ret != DEVICE_OK)     return ret;   .... }<\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043e\u043f\u044f\u0442\u044c \u043d\u0435 \u0438\u043c\u0435\u0435\u0442. \u041f\u0435\u0440\u0435\u0434 \u043d\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f &#8216;ret&#8217; \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f. \u0412\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c. <\/p>\n<p>  \u0422\u0430\u043a\u0438\u0445 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e. \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u043c: <a href=\"http:\/\/www.viva64.com\/external-pictures\/txt\/Micro-Manager-V571-V649.txt\">Micro-Manager-V571-V649.txt<\/a>.<\/p>\n<p>  \u0415\u0449\u0451 \u0438\u0437 \u043c\u0435\u043b\u043e\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 sprintf(). \u0411\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u0437\u043d\u0430\u043a\u043e\u0432\u0430\u044f. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u043a\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.  <\/p>\n<pre><code class=\"cpp\">int MP285Ctrl::Initialize() {   ....   unsigned int nUm2UStepUnit = MP285::Instance()-&gt;GetUm2UStep();   ....   sprintf(sUm2UStepUnit, &quot;%d&quot;, nUm2UStepUnit);   .... }<\/code><\/pre>\n<p>  \u041d\u0430\u0448\u043b\u043e\u0441\u044c \u0442\u0440\u0438 \u0442\u0430\u043a\u0438\u0445 \u043c\u0435\u0441\u0442\u0430:<\/p>\n<ul>\n<li>V576 Incorrect format. Consider checking the third actual argument of the &#8216;sprintf&#8217; function. The SIGNED integer type argument is expected. MP285Ctrl.cpp 253<\/li>\n<li>V576 Incorrect format. Consider checking the third actual argument of the &#8216;sprintf&#8217; function. The SIGNED integer type argument is expected. MP285Ctrl.cpp 276<\/li>\n<li>V576 Incorrect format. Consider checking the third actual argument of the &#8216;sprintf&#8217; function. The SIGNED integer type argument is expected. MP285Ctrl.cpp 327<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0415\u0434\u0438\u043d\u0438\u0447\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044d\u0442\u043e\u0433\u043e \u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u0430\u043b\u043e\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430. \u041f\u043e\u043b\u044c\u0437\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432 \u043a\u043e\u0434\u0430. \u0422\u043e\u0433\u0434\u0430 \u043c\u043d\u043e\u0433\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0440\u0430\u043d\u043d\u0435\u043c \u044d\u0442\u0430\u043f\u0435. \u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0439\u0442\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437, \u043a\u0430\u043a \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0434\u0430\u0451\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440.<\/p>\n<p>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430\u043c, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u0438 \u043a\u0440\u0443\u043f\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b Windows, \u043c\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 <a href=\"http:\/\/www.viva64.com\/ru\/b\/0222\/\">PVS-Studio<\/a>. \u0426\u0435\u043d\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043c\u044b \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 <a href=\"http:\/\/www.cppcat.com\/\">CppCat<\/a>. \u0418\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u044f \u2014 $250. \u041f\u0440\u043e\u0434\u043b\u0435\u043d\u0438\u0435 \u2014 $200. \u041f\u0440\u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0439 \u2014 \u0441\u043a\u0438\u0434\u043a\u0438.<\/p>\n<p>  \u0422\u0435\u043c, \u043a\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 Linux, \u043c\u044b \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043a\u043e\u0434\u0430 <a href=\"http:\/\/www.viva64.com\/ru\/t\/0083\/\">Cppcheck<\/a>. \u0418\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/www.viva64.com\/ru\/b\/0219\/\">Standalone<\/a> \u0432\u0435\u0440\u0441\u0438\u044e PVS-Studio.<\/p>\n<h2>P.S.<\/h2>\n<p>  \u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438: &quot;<a href=\"http:\/\/www.viva64.com\/en\/b\/0242\/\">The Unicorn&#8217;s Travel to the Microcosm<\/a>&quot;.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044e \u0438 \u0441\u0440\u0430\u0437\u0443 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c?<\/b><\/p>\n<div class=\"spoiler_text\">\u0427\u0430\u0441\u0442\u043e \u043a \u043d\u0430\u0448\u0438\u043c \u0441\u0442\u0430\u0442\u044c\u044f\u043c \u0437\u0430\u0434\u0430\u044e\u0442 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b. \u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u043d\u0438\u0445 \u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0437\u0434\u0435\u0441\u044c: <a href=\"http:\/\/www.viva64.com\/ru\/a\/0085\/\">\u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e PVS-Studio \u0438 CppCat, \u0432\u0435\u0440\u0441\u0438\u044f 2014<\/a>. \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c.  <\/div>\n<\/div>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/company\/pvs-studio\/blog\/216157\/\"> http:\/\/habrahabr.ru\/company\/pvs-studio\/blog\/216157\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/2b1\/578\/3f2\/2b15783f2f481b823c3b50bcadaca205.png\" alt=\"PVS-Studio and \u03bcManager (Micro-Manager)\" align=\"left\"\/><br \/>  \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0430\u043c \u043f\u0440\u0435\u043f\u043e\u0434\u043d\u0451\u0441 \u043c\u0438\u043a\u0440\u043e\u043c\u0438\u0440. \u041c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u043a\u043e\u0434\u0430 PVS-Studio \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u03bcManager. \u042d\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043c\u0438\u043a\u0440\u043e\u0441\u043a\u043e\u043f\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-216157","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/216157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=216157"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/216157\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=216157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=216157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=216157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}