{"id":282334,"date":"2016-12-12T09:55:04","date_gmt":"2016-12-12T06:55:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=282334"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=282334","title":{"rendered":"\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c Linux-\u0432\u0435\u0440\u0441\u0438\u044e PVS-Studio \u043d\u0430 Linux Kernel"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fec\/53e\/cf2\/fec53ecf27f5499dbf1bb8068af5761a.png\"\/><\/p>\n<p>  \u0421 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0445\u043e\u0434\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0439 Linux-\u0432\u0435\u0440\u0441\u0438\u0438 PVS-Studio, \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u044f\u0434\u0440\u0430 Linux \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u043b\u0438\u0448\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u0430\u043c\u0438 \u0441\u043e \u0432\u0441\u0435\u0433\u043e \u043c\u0438\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439 \u0432 \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0444\u0435\u0440\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u043c \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430. \u041a\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 PVS-Studio \u0432 \u0442\u0430\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445?<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h2>\u041a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438<\/h2>\n<p>  \u041c\u044b <a href=\"http:\/\/www.viva64.com\/ru\/b\/0299\/\">\u0443\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438<\/a> \u044f\u0434\u0440\u043e Linux. \u0421 \u0442\u0435\u0445 \u043f\u043e\u0440 \u043c\u043d\u043e\u0433\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u041e\u0421 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u0430 \u0438 \u0443\u0434\u043e\u0431\u043d\u0430, \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:  <\/p>\n<pre><code class=\"cpp\">pvs-studio-analyzer trace - make pvs-studio-analyzer analyze -o \/path\/to\/report.log -j8<\/code><\/pre>\n<p>  \u0412\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0443\u0448\u043b\u043e \u043d\u0430 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044e \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0432 Linux, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u044b\u043b \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f Windows. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044f\u0434\u0440\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u043e\u0449\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0431\u044b\u043b\u0430 \u0432\u0437\u044f\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f 4.9-rc4 (commit bc33b0ca11e3df467777a4fa7639ba488c9d4911).<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 \u043e\u0431\u0449\u0435\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 1-2 \u0443\u0440\u043e\u0432\u043d\u0435\u0439. \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430 \u2014 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0438\u0437\u043a\u0430\u044f.<\/p>\n<p>  \u0414\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u0432\u044b\u0431\u0438\u0440\u0430\u043b \u0442\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438\/\u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0438. \u041d\u0430\u0434\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u043c\u0438\u043c\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0432\u044b\u0434\u0430\u0451\u0442 \u0438 \u043b\u043e\u0436\u043d\u044b\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0432\u044b\u044f\u0432\u043b\u044f\u0435\u0442 \u043f\u043b\u043e\u0445\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043b\u0438 \u00ab\u0434\u0443\u0440\u043d\u043e \u043f\u0430\u0445\u043d\u0443\u0449\u0438\u0439\u00bb \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u043c.<\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 \u043f\u043e\u0434 Linux \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b. \u0414\u0443\u043c\u0430\u044e, \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u043d\u043e \u0441 \u043c\u043e\u043b\u043e\u0434\u043e\u0441\u0442\u044c\u044e \u0432\u0435\u0440\u0441\u0438\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u044f Linux \u0441\u0438\u0441\u0442\u0435\u043c. \u041c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b\u0438 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439. \u041a\u043e\u0434 Linux \u043f\u043e\u043c\u043e\u0433 \u043d\u0430\u043c \u0441\u0442\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u0438 \u0432\u043d\u0435\u0441\u0442\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<h2>\u041e\u043f\u0435\u0447\u0430\u0442\u043a\u0438<\/h2>\n<p>  \u0421\u0430\u043c\u0430\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u0430\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430\u043c\u0438 \u0438 <a href=\"http:\/\/www.viva64.com\/ru\/t\/0068\/\">Copy-Paste<\/a>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0447\u0438\u0442\u0430\u043b\u0438 \u043d\u0430\u0448\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0440\u0430\u043d\u044c\u0448\u0435, \u044f \u0434\u0443\u043c\u0430\u044e, \u0432\u044b \u0443\u0436\u0435 \u0432 \u044d\u0442\u043e\u043c \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c. \u041e\u043d\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043b\u044e\u0431\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043d\u0430 \u043b\u044e\u0431\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u043d\u0430 \u043b\u044e\u0431\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445. \u0412 \u0442\u0430\u043a\u0438\u0445 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430: \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u0430\u0439\u0442\u0438 \u0438\u0445 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0441 \u043d\u0438\u043c\u0438 \u043e\u0431\u0441\u0442\u043e\u044f\u0442 \u0434\u0435\u043b\u0430 \u0432 \u044f\u0434\u0440\u0435 Linux:<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V581\/\">V581<\/a> The conditional expressions of the &#8216;if&#8217; operators situated alongside each other are identical. Check lines: 2384, 2390. debug.c 2390  <\/p>\n<pre><code class=\"cpp\">int dbg_check_nondata_nodes_order(....) {   ....   sa = container_of(cur, struct ubifs_scan_node, list);   sb = container_of(cur-&gt;next, struct ubifs_scan_node, list);    if (sa-&gt;type != UBIFS_INO_NODE &amp;&amp; sa-&gt;type != UBIFS_DENT_NODE &amp;&amp;       sa-&gt;type != UBIFS_XENT_NODE) {     ubifs_err(c, &quot;bad node type %d&quot;, sa-&gt;type);     ubifs_dump_node(c, sa-&gt;node);     return -EINVAL;   }   if (sa-&gt;type != UBIFS_INO_NODE &amp;&amp; sa-&gt;type != UBIFS_DENT_NODE &amp;&amp;       sa-&gt;type != UBIFS_XENT_NODE) {     ubifs_err(c, &quot;bad node type %d&quot;, sb-&gt;type);     ubifs_dump_node(c, sb-&gt;node);     return -EINVAL;   }   .... }<\/code><\/pre>\n<p>  \u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0436\u0430\u043b\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e\u0434\u0440\u044f\u0434: \u0432\u0438\u0434\u0438\u043c\u043e, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u0431\u044b\u043b\u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c <i>sa <\/i>\u043d\u0430 <i>sb<\/i>. \u041d\u0443 \u0438 \u043a\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0430\u0436\u0435\u0442, \u0447\u0442\u043e \u0432 \u043a\u0440\u0443\u0442\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043d\u0435 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u044f\u0442?<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V666\/\">V666<\/a> Consider inspecting third argument of the function &#8216;strncmp&#8217;. It is possible that the value does not correspond with the length of a string which was passed with the first argument. spectral.c 341  <\/p>\n<pre><code class=\"cpp\">static ssize_t write_file_spec_scan_ctl(struct file *file,           const char __user *user_buf,           size_t count, loff_t *ppos) {   struct ath10k *ar = file-&gt;private_data;   char buf[32];   ssize_t len;   int res;    len = min(count, sizeof(buf) - 1);   if (copy_from_user(buf, user_buf, len))     return -EFAULT;    buf[len] = '\\0';    mutex_lock(&amp;ar-&gt;conf_mutex);    if (strncmp(&quot;trigger&quot;, buf, 7) == 0) {     ....   } else if (strncmp(&quot;background&quot;, buf, 9) == 0) {     res = ath10k_spectral_scan_config(ar, SPECTRAL_BACKGROUND);   } else if (strncmp(&quot;manual&quot;, buf, 6) == 0) {     res = ath10k_spectral_scan_config(ar, SPECTRAL_MANUAL);   } else if (strncmp(&quot;disable&quot;, buf, 7) == 0) {     res = ath10k_spectral_scan_config(ar, SPECTRAL_DISABLED);   } else {     res = -EINVAL;   }    mutex_unlock(&amp;ar-&gt;conf_mutex);    if (res &lt; 0)     return res;    return count; }<\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u0438\u0434 \u043e\u0448\u0438\u0431\u043a\u0438: \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430: \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0435\u0451 \u0434\u043b\u0438\u043d\u0443. \u0427\u0430\u0441\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0441\u043b\u0443\u0436\u0438\u0442 \u043b\u0438\u0442\u0435\u0440\u0430\u043b, \u0434\u043b\u0438\u043d\u0443 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043b\u0435\u043d\u044f\u0442\u0441\u044f \u0438 \u043f\u0438\u0448\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0438\u0441\u043b\u043e. \u0412 \u0434\u0435\u043b\u043e \u0432\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u0438\u0439 \u0444\u0430\u043a\u0442\u043e\u0440: \u043e\u0448\u0438\u0431\u0430\u044e\u0442\u0441\u044f <a href=\"http:\/\/www.viva64.com\/ru\/examples\/v666\/\">\u0447\u0430\u0441\u0442\u043e<\/a>.<\/p>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u0432 \u043a\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0440\u044f\u0434 <i>strncmp<\/i>. \u0412 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u043b\u0438\u0442\u0435\u0440\u0430\u043b. \u0418 \u0432 <i>strncmp(\u00abbackground\u00bb, buf, 9)<\/i> \u0434\u043b\u0438\u043d\u0443 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u043d\u0435\u0432\u0435\u0440\u043d\u043e: \u0441\u043b\u043e\u0432\u043e \u00abbackground\u00bb \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 10, \u0430 \u043d\u0435 \u0438\u0437 9 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V666\/\">V666<\/a> Consider inspecting third argument of the function &#8216;memcpy&#8217;. It is possible that the value does not correspond with the length of a string which was passed with the second argument. dpt_i2o.c 403  <\/p>\n<pre><code class=\"cpp\">static void adpt_inquiry(adpt_hba* pHba) {   ....   memset(pHba-&gt;detail, 0, sizeof(pHba-&gt;detail));   memcpy(&amp;(pHba-&gt;detail), &quot;Vendor: Adaptec &quot;, 16);   memcpy(&amp;(pHba-&gt;detail[16]), &quot; Model: &quot;, 8);   memcpy(&amp;(pHba-&gt;detail[24]), (u8*) &amp;buf[16], 16);   memcpy(&amp;(pHba-&gt;detail[40]), &quot; FW: &quot;, 4);         \/\/ &lt;=   memcpy(&amp;(pHba-&gt;detail[44]), (u8*) &amp;buf[32], 4);   pHba-&gt;detail[48] = '\\0';  \/* precautionary *\/   .... }<\/code><\/pre>\n<p>  \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440. \u0414\u043b\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 &quot; FW: &quot; \u0440\u0430\u0432\u043d\u0430 5, \u0430 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 4 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c.<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438? \u0412 C \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441 \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435:  <\/p>\n<pre><code class=\"cpp\">#define str_len(S) (sizeof(S) \/ sizeof((S)[0]))<\/code><\/pre>\n<p>  \u041d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0441\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u043f\u0430\u0441\u043d\u043e: \u043b\u0443\u0447\u0448\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c compiler-specific \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<p>  \u0414\u043b\u044f \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u0438\u0448\u0443\u0449\u0438\u0445 \u043d\u0430 C++, \u043c\u043e\u0433\u0443 \u043f\u043e\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c std::string_view, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0432 C++17. \u041b\u0443\u0447\u0448\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0430\u0440\u043e\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c-\u0434\u043b\u0438\u043d\u0430. \u041d\u043e \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e memcpy), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c std::size(array) \u0438\u043b\u0438 \u0435\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433: \u0434\u043b\u044f \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043d \u0432 compile-time.<\/p>\n<p>  \u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0438 \u043d\u0435 \u043b\u0435\u043d\u0438\u0442\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u044f\u0437\u044b\u043a\u0430 (\u0431\u0443\u0434\u044c \u0442\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b) \u0434\u043b\u044f compile time \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439!<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V653\/\">V653<\/a> A suspicious string consisting of two parts is used for array initialization. It is possible that a comma is missing. Consider inspecting this literal: \u00ab30min\u00bb \u00abNo timeout\u00bb. lp8788-charger.c 657  <\/p>\n<pre><code class=\"cpp\">static ssize_t lp8788_show_eoc_time(struct device *dev,         struct device_attribute *attr, char *buf) {   struct lp8788_charger *pchg = dev_get_drvdata(dev);   char *stime[] = { &quot;400ms&quot;, &quot;5min&quot;, &quot;10min&quot;, &quot;15min&quot;,       &quot;20min&quot;, &quot;25min&quot;, &quot;30min&quot; &quot;No timeout&quot; };   .... }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0434\u0432\u0430 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0440\u044f\u0434 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0445 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u0445. \u041e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432: \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u00ab\u0441\u043b\u0438\u043f\u043d\u0443\u0442\u0441\u044f\u00bb \u0434\u0432\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u00ab30minNo timeout\u00bb. \u042d\u0442\u043e \u0434\u0432\u043e\u0439\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0442\u0435\u043a\u0441\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0432\u044b\u0445\u043e\u0434\u0443 \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<p>  \u0421\u043e\u0432\u0435\u0442\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432 \u043d\u0451\u043c \u0442\u0430\u043a\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0441\u0442\u0430\u043d\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0439:  <\/p>\n<pre><code class=\"cpp\">char *stime[] = {     &quot;400ms&quot;   , &quot;5min&quot;   , &quot;10min&quot;   , &quot;15min&quot;   , &quot;20min&quot;   , &quot;25min&quot;   , &quot;30min&quot;     &quot;No timeout&quot; };<\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0442\u0430\u043a\u043e\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u0438\u0441\u0430\u043b \u043c\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u0433\u0430 \u0410\u043d\u0434\u0440\u0435\u0439 \u041a\u0430\u0440\u043f\u043e\u0432. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0433\u043b\u0430\u0432\u043e\u0439 N13 \u0438\u0437 \u0435\u0433\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 <a href=\"http:\/\/www.viva64.com\/ru\/b\/0391\/\">\u043a\u043d\u0438\u0433\u0438<\/a>.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V764\/\">V764<\/a> Possible incorrect order of arguments passed to &#8216;ahc_9005_subdevinfo_valid&#8217; function: &#8216;device&#8217; and &#8216;vendor&#8217;. aic7xxx_pci.c 695  <\/p>\n<pre><code class=\"cpp\">const struct ahc_pci_identity * ahc_find_pci_device(ahc_dev_softc_t pci) {   ....   if (ahc_get_pci_function(pci) &gt; 0    &amp;&amp; ahc_9005_subdevinfo_valid(device, vendor, \/\/ &lt;=                                 subdevice, subvendor)    &amp;&amp; SUBID_9005_MFUNCENB(subdevice) == 0)     return (NULL);    .... }<\/code><\/pre>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u0430 \u0447\u0442\u043e \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440. \u041a\u0441\u0442\u0430\u0442\u0438, \u0442\u0430\u043a\u043e\u0435 \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442: \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043d\u0435 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0435\u043c\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b \u043d\u0430\u043c \u043e\u0442\u0447\u0451\u0442 \u0441 \u00ab\u043b\u043e\u0436\u043d\u044b\u043c \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435\u043c\u00bb, \u0430 \u0442\u0430\u043c \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u0448\u0438\u0431\u043a\u0430. \u0412\u043e\u0442 \u0438 \u043c\u043d\u0435 \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043b\u043e\u0436\u043d\u043e\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435: \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043f\u043e \u043a\u043e\u0434\u0443 \u0438 \u0442\u0430\u043c \u0432\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u0412\u043e\u0442 \u043a\u0430\u043a \u043e\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:  <\/p>\n<pre><code class=\"cpp\">static int ahc_9005_subdevinfo_valid(uint16_t device, uint16_t vendor,         uint16_t subdevice, uint16_t subvendor) {   .... }<\/code><\/pre>\n<p>  \u0412 \u0447\u0451\u043c \u0436\u0435 \u0434\u0435\u043b\u043e? \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0449\u0451 \u0432\u044b\u0448\u0435 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0432\u043e\u0442 \u0442\u0430\u043c-\u0442\u043e \u044d\u0442\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u043d\u044b. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e \u0432 \u043b\u043e\u0433\u0438\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0435\u0442, \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u0434\u0430\u0431\u044b \u043d\u0438\u043a\u043e\u0433\u043e \u043d\u0435 \u0441\u043c\u0443\u0449\u0430\u0442\u044c \u0438 \u043d\u0435 \u0441\u0431\u0438\u0432\u0430\u0442\u044c \u0441 \u0442\u043e\u043b\u043a\u0443.  <\/p>\n<pre><code class=\"cpp\">static int ahc_9005_subdevinfo_valid(uint16_t vendor, uint16_t device,     uint16_t subvendor, uint16_t subdevice);<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/93a\/4d7\/27b\/93a4d727b79846b8a7d99224806c02ea.png\"\/><\/p>\n<p>  \u041d\u043e \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0437\u0430\u0431\u0430\u0432\u043d\u043e\u0435, \u043e\u0448\u0438\u0431\u043a\u0430 \u0437\u0434\u0435\u0441\u044c <a href=\"https:\/\/kernel.googlesource.com\/pub\/scm\/linux\/kernel\/git\/stable\/linux-stable\/+\/6f8f8e4d313a47e3f8aa7eeb5201d1b02ffa0951%5E!\/\">\u0443\u0436\u0435 \u0431\u044b\u043b\u0430<\/a>: \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u043d\u044b, \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0431\u044b\u043b\u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435. \u0425\u043e\u0440\u043e\u0448\u043e, \u0447\u0442\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0442\u043e\u0436\u0435 \u043d\u0430\u0448\u0451\u043b \u044d\u0442\u043e \u043c\u0435\u0441\u0442\u043e.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V549\/\">V549<\/a> The first argument of &#8216;memcpy&#8217; function is equal to the second argument. wilc_wfi_cfgoperations.c 1345  <\/p>\n<pre><code class=\"cpp\">static int del_pmksa(struct wiphy *wiphy,                      struct net_device *netdev,                      struct cfg80211_pmksa *pmksa) {   ....   for (; i &lt; (priv-&gt;pmkid_list.numpmkid - 1); i++) {     memcpy(priv-&gt;pmkid_list.pmkidlist[i].bssid,            priv-&gt;pmkid_list.pmkidlist[i + 1].bssid,            ETH_ALEN);     memcpy(priv-&gt;pmkid_list.pmkidlist[i].pmkid,            priv-&gt;pmkid_list.pmkidlist[i].pmkid,            PMKID_LEN);   }   .... }<\/code><\/pre>\n<p>  \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c <i>memcpy<\/i> \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0445\u043e\u0442\u0435\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c:  <\/p>\n<pre><code class=\"cpp\">memcpy(priv-&gt;pmkid_list.pmkidlist[i].pmkid,        priv-&gt;pmkid_list.pmkidlist[i + 1].pmkid,        PMKID_LEN);<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/h2>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V575\/\">V575<\/a> The &#8216;strncasecmp&#8217; function processes &#8216;0&#8217; elements. Inspect the third argument. linux_wlan.c 1121  <\/p>\n<pre><code class=\"cpp\">static int mac_ioctl(struct net_device *ndev,                      struct ifreq *req,                      int cmd) {   u8 *buff = NULL;   s8 rssi;   u32 size = 0, length = 0;   struct wilc_vif *vif;   s32 ret = 0;   struct wilc *wilc;    vif = netdev_priv(ndev);   wilc = vif-&gt;wilc;    if (!wilc-&gt;initialized)     return 0;    switch (cmd) {   case SIOCSIWPRIV:   {     struct iwreq *wrq = (struct iwreq *)req;      size = wrq-&gt;u.data.length;      if (size &amp;&amp; wrq-&gt;u.data.pointer) {       buff = memdup_user(wrq-&gt;u.data.pointer,                          wrq-&gt;u.data.length);       if (IS_ERR(buff))         return PTR_ERR(buff);        if (strncasecmp(buff, &quot;RSSI&quot;, length) == 0) { \/\/ &lt;=         ....       }     }   }   ....   }  done:    kfree(buff);    return ret; }<\/code><\/pre>\n<p>  \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>strncasecmp <\/i> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u0438\u043d\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 <i>0<\/i>. \u0412 \u043a\u043e\u0434\u0435 \u043d\u0435\u0442 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u0431\u044b \u0438\u0437\u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <i>length<\/i>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0443\u043b\u0451\u043c. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <i>size<\/i>.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V751\/\">V751<\/a> Parameter &#8216;LCDheight&#8217; is not used inside function body. init.c 339  <\/p>\n<pre><code class=\"cpp\">static unsigned short SiS_GetModeID(int VGAEngine, unsigned int VBFlags,               int HDisplay, int VDisplay,               int Depth, bool FSTN,               int LCDwidth, int LCDheight) {   unsigned short ModeIndex = 0;    switch(HDisplay)   {   case 320:     if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth];     else if(VDisplay == 240) {       if((VBFlags &amp; CRT2_LCD) &amp;&amp; (FSTN))         ModeIndex = ModeIndex_320x240_FSTN[Depth];       else         ModeIndex = ModeIndex_320x240[Depth];     }     break;   case 400:     if((!(VBFlags &amp; CRT1_LCDA)) ||        ((LCDwidth &gt;= 800) &amp;&amp; (LCDwidth &gt;= 600))) { \/\/ &lt;=       if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth];     }     break;   case 512:     if((!(VBFlags &amp; CRT1_LCDA)) ||        ((LCDwidth &gt;= 1024) &amp;&amp; (LCDwidth &gt;= 768))) { \/\/ &lt;=       if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth];     }     break;     ....   }    return ModeIndex; }<\/code><\/pre>\n<p>  \u041d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u2014 \u044d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430. \u0412 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0442\u0430\u0440\u044b\u0445 API \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u0442\u0430\u043b \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0438 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442. \u041d\u043e \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u0441\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u043a \u044d\u0442\u043e\u043c\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0443: \u0437\u0434\u0435\u0441\u044c \u0437\u0430\u0431\u044b\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0430 <i>&#8216;(A &gt; 5) &amp;&amp; (A &gt; 3)&#8217;<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b.<\/p>\n<h2>\u041f\u0443\u0442\u0430\u043d\u0438\u0446\u0430 \u0432 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439<\/h2>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V502\/\">V502<\/a> Perhaps the &#8216;?:&#8217; operator works in a different way than it was expected. The &#8216;?:&#8217; operator has a lower priority than the &#8216;|&#8217; operator. core.c 1046  <\/p>\n<pre><code class=\"cpp\">static int nvme_pr_preempt(struct block_device *bdev,                            u64 old, u64 new,                            enum pr_type type, bool abort) {   u32 cdw10 = nvme_pr_type(type) &lt;&lt; 8 | abort ? 2 : 1;   return nvme_pr_command(bdev, cdw10, old, new,                          nvme_cmd_resv_acquire); }<\/code><\/pre>\n<p>  \u0422\u0435\u0440\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432 C \u2014 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440. \u041d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u043e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0435\u0440\u0432\u044b\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a \u043e\u0431\u0449\u0435\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 PVS-Studio \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0435\u043c\u0443. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442, \u0438 \u0432 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0438\u043d\u043e\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0435\u0448\u044c\u0441\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u043e\u0431\u043a\u0438.<\/p>\n<h2>\u041f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/h2>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V517\/\">V517<\/a> 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: 375, 377. trx.c 375  <\/p>\n<pre><code class=\"cpp\">bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw,          struct rtl_stats *status,          struct ieee80211_rx_status *rx_status,          u8 *pdesc, struct sk_buff *skb) {   struct rtl_priv *rtlpriv = rtl_priv(hw);   struct rx_fwinfo *p_drvinfo;   struct ieee80211_hdr *hdr;   u32 phystatus = GET_RX_DESC_PHYST(pdesc);    ....    status-&gt;macid = GET_RX_DESC_MACID(pdesc);   if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc))     status-&gt;wake_match = BIT(2);   else if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc))     status-&gt;wake_match = BIT(1);   else if (GET_RX_STATUS_DESC_UNICAST_MATCH(pdesc))     status-&gt;wake_match = BIT(0);   else     status-&gt;wake_match = 0;      .... }<\/code><\/pre>\n<p>  \u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0442\u0430\u043a. \u0414\u0432\u0430 \u0440\u0430\u0437\u0430 \u0438\u0434\u0451\u0442 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c <i>GET_RX_STATUS_DESC_MAGIC_MATCH<\/i>. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u0434\u0432\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u0430:  <\/p>\n<pre><code class=\"cpp\">#define GET_RX_STATUS_DESC_PATTERN_MATCH(__pdesc)         LE_BITS_TO_4BYTE(__pdesc+12, 29, 1) #define GET_RX_STATUS_DESC_UNICAST_MATCH(__pdesc)         LE_BITS_TO_4BYTE(__pdesc+12, 30, 1) #define GET_RX_STATUS_DESC_MAGIC_MATCH(__pdesc)         LE_BITS_TO_4BYTE(__pdesc+12, 31, 1)<\/code><\/pre>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0445\u043e\u0442\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435 <i>GET_RX_STATUS_DESC_PATTERN_MATCH<\/i>. \u0418\u043d\u0430\u0447\u0435 \u044d\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u0430.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V547\/\">V547<\/a> Expression &#8216;(ptr[3] &amp; 0x1E) != 0x03&#8217; is always true. sd.c 4115  <\/p>\n<pre><code class=\"cpp\">int ext_sd_send_cmd_get_rsp(struct rtsx_chip *chip,     u8 cmd_idx, u32 arg, u8 rsp_type,     u8 *rsp, int rsp_len, bool special_check) {   int retval;   int timeout = 100;   u16 reg_addr;   u8 *ptr;    ....    if (cmd_idx == SELECT_CARD) {     if (rsp_type == SD_RSP_TYPE_R2) {       if ((ptr[3] &amp; 0x1E) != 0x04) {         rtsx_trace(chip);         return STATUS_FAIL;       }      } else if (rsp_type == SD_RSP_TYPE_R0) {       if ((ptr[3] &amp; 0x1E) != 0x03) {           \/\/ &lt;=         rtsx_trace(chip);         return STATUS_FAIL;       }     }   }    .... }<\/code><\/pre>\n<p>  \u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0431\u0438\u0442\u043e\u0432\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043a\u043e\u043d\u044a\u044e\u043d\u043a\u0446\u0438\u0438 \u0441 <i>0x1E<\/i> \u0438\u0437-\u0437\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0431\u0438\u0442\u0430 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e <i>0x03<\/i>:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6fc\/0c2\/b6f\/6fc0c2b6fdd745e6a8e3d883fe5ddff2.png\"\/><\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V517\/\">V517<\/a> 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: 1277, 1282. ks_wlan_net.c 1277  <\/p>\n<pre><code class=\"cpp\">static int ks_wlan_set_power(struct net_device *dev,            struct iw_request_info *info,            struct iw_param *vwrq, char *extra) {   struct ks_wlan_private *priv =       (struct ks_wlan_private *)netdev_priv(dev);   short enabled;    if (priv-&gt;sleep_mode == SLP_SLEEP) {     return -EPERM;   }   \/* for SLEEP MODE *\/   enabled = vwrq-&gt;disabled ? 0 : 1;   if (enabled == 0) {  \/* 0 *\/     priv-&gt;reg.powermgt = POWMGT_ACTIVE_MODE;   } else if (enabled) {  \/* 1 *\/     if (priv-&gt;reg.operation_mode == MODE_INFRASTRUCTURE)       priv-&gt;reg.powermgt = POWMGT_SAVE1_MODE;     else       return -EINVAL;   } else if (enabled) {  \/* 2 *\/     if (priv-&gt;reg.operation_mode == MODE_INFRASTRUCTURE)       priv-&gt;reg.powermgt = POWMGT_SAVE2_MODE;     else       return -EINVAL;   } else     return -EINVAL;    hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);    return 0; }<\/code><\/pre>\n<p>  \u0421\u043e\u043a\u0440\u0430\u0442\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e:  <\/p>\n<pre><code class=\"cpp\">enabled = vwrq-&gt;disabled ? 0 : 1; if (enabled == 0)   {  \/* 0 *\/   .... } else if (enabled) {  \/* 1 *\/   .... } else if (enabled) {  \/* 2 *\/   .... } else   ....<\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u043e. \u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0447\u0451\u0442\u043a\u043e \u043e\u0431\u0433\u043e\u0432\u043e\u0440\u0435\u043d\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0432\u044b\u0448\u0435: <i>enabled <\/i> \u0440\u0430\u0432\u0435\u043d <i>0<\/i> \u0438\u043b\u0438 <i>1<\/i>. \u041d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0446\u0435\u043b\u044b\u0445 <i>4<\/i> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0448\u0430\u044e\u0442: \u0435\u0441\u043b\u0438 \u0446\u0438\u0444\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u0438 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438: \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 <i>1<\/i> \u0438 <i>2<\/i> \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V517\/\">V517<\/a> 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: 422, 424. Hal8188ERateAdaptive.c 422  <\/p>\n<pre><code class=\"cpp\">static int odm_ARFBRefresh_8188E(         struct odm_dm_struct *dm_odm,         struct odm_ra_info *pRaInfo) {  \/*  Wilson 2011\/10\/26 *\/   ....   if (pRaInfo-&gt;HighestRate &gt; 0x13)     pRaInfo-&gt;PTModeSS = 3;   else if (pRaInfo-&gt;HighestRate &gt; 0x0b)     pRaInfo-&gt;PTModeSS = 2;   else if (pRaInfo-&gt;HighestRate &gt; 0x0b)     pRaInfo-&gt;PTModeSS = 1;   else     pRaInfo-&gt;PTModeSS = 0;   ....   return 0; }<\/code><\/pre>\n<p>  \u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u043c\u0435\u0441\u0442\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0434\u0443\u0442 \u043f\u043e\u0434\u0440\u044f\u0434 \u0434\u0432\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0442\u0435\u043b\u0430 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u043d\u044b\u0435. \u0421\u043b\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0437\u0434\u0435\u0441\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u0438\u043b\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434: \u044d\u0442\u043e \u0443\u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0417\u0430\u0434\u0430\u0447\u0430 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V734\/\">V734<\/a> An excessive check. Examine the conditions containing search for the substrings \u00abinterleaver\u00bb and \u00abdeinterleaver\u00bb. sst-atom-controls.c 1449  <\/p>\n<pre><code class=\"cpp\">static int sst_fill_widget_module_info(   struct snd_soc_dapm_widget *w,   struct snd_soc_platform *platform) {   struct snd_kcontrol *kctl;   int index, ret = 0;   struct snd_card *card = platform-&gt;component.card-&gt;snd_card;   char *idx;    down_read(&amp;card-&gt;controls_rwsem);    list_for_each_entry(kctl, &amp;card-&gt;controls, list) {     ....      } else if (strstr(kctl-&gt;id.name, &quot;interleaver&quot;)) {       struct sst_enum *e = (void *)kctl-&gt;private_value;        e-&gt;w = w;      } else if (strstr(kctl-&gt;id.name, &quot;deinterleaver&quot;)) {       struct sst_enum *e = (void *)kctl-&gt;private_value;        e-&gt;w = w;     }      ....   }    up_read(&amp;card-&gt;controls_rwsem);   return 0; }<\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435. \u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u044f \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0441 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043d\u0430\u0448\u043b\u0438 <i>interleaver <\/i> \u2014 \u0442\u043e\u0433\u0434\u0430 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0438\u0441\u043a\u0430\u0442\u044c <i>deinterleaver<\/i>, \u0432\u0435\u0434\u044c \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 <i>interleaver <\/i> \u0443\u0436\u0435 \u0442\u043e\u0447\u043d\u043e \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0442 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u043a\u043e\u0434\u0430 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u043b\u0430 \u0443 if \u0438 else \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435, \u044d\u0442\u043e \u043d\u0435 \u0441\u0442\u0440\u0430\u0448\u043d\u043e. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V547\/\">V547<\/a> Expression &#8216;block&#8217; is always true. svclock.c 873  <\/p>\n<pre><code class=\"cpp\">void nlmsvc_grant_reply(struct nlm_cookie *cookie, __be32 status) {   struct nlm_block  *block;    dprintk(&quot;grant_reply: looking for cookie %x, s=%d \\n&quot;,     *(unsigned int *)(cookie-&gt;data), status);   if (!(block = nlmsvc_find_block(cookie)))     return;    if (block) {     if (status == nlm_lck_denied_grace_period) {       \/* Try again in a couple of seconds *\/       nlmsvc_insert_block(block, 10 * HZ);     } else {       \/* Lock is now held by client, or has been rejected.        * In both cases, the block should be removed. *\/       nlmsvc_unlink_block(block);     }   }   nlmsvc_release_block(block); }<\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0443 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c Pattern-based analysis, \u043e\u0431\u0445\u043e\u0434\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Abstract_syntax_tree\">AST<\/a>. \u0412\u0430\u0436\u043d\u043e \u0443\u043c\u0435\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c Control flow analysis \u0438 Data flow analysis. \u0412 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 <i>block == NULL<\/i> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 <i>return<\/i>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u043a\u043e\u0434\u0443 \u043c\u044b \u0442\u043e\u0447\u043d\u043e \u043c\u043e\u0436\u0435\u043c \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439. \u0418 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 <i>NULL<\/i>, \u043c\u044b \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u0442\u0443\u0442 \u043d\u0435 \u0442\u0430\u043a.<\/p>\n<p>  \u041f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438\u0448\u043d\u044f\u044f. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u0434\u0440\u0443\u0433 \u0437\u0434\u0435\u0441\u044c \u0445\u043e\u0442\u0435\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e? \u041a\u0442\u043e \u0437\u043d\u0430\u0435\u0442\u2026 \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0443 \u044f\u0432\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<p>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f:<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V547\/\">V547<\/a> Expression &#8216;sym&#8217; is always true. menu.c 498  <\/p>\n<pre><code class=\"cpp\">bool menu_is_visible(struct menu *menu) {   struct menu *child;   struct symbol *sym;    ....    if (!sym || sym_get_tristate_value(menu-&gt;sym) == no) \/\/ &lt;=     return false;    for (child = menu-&gt;list; child; child = child-&gt;next) {     if (menu_is_visible(child)) {       if (sym)                                         \/\/ &lt;=         sym-&gt;flags |= SYMBOL_DEF_USER;       return true;     }   }    return false; }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043c\u0430\u043a\u0440\u043e\u0441\u0435<\/h2>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V733\/\">V733<\/a> It is possible that macro expansion resulted in incorrect evaluation order. Check expression: request-&gt;rq_timeout + 5 * 1000. niobuf.c 637  <\/p>\n<pre><code class=\"cpp\">#define CFS_FAIL_TIMEOUT(id, secs) \\ cfs_fail_timeout_set(id, 0, secs * 1000, CFS_FAIL_LOC_NOSET)  #define OBD_FAIL_TIMEOUT(id, secs) \\ CFS_FAIL_TIMEOUT(id, secs)  int ptl_send_rpc(struct ptlrpc_request *request, int noreply) {   ....   OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND,                    request-&gt;rq_timeout + 5);   .... }<\/code><\/pre>\n<p>  \u0410 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u0434\u043a\u0438. \u0414\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u0438\u0434\u0435\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435: \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u044b\u043b <a href=\"http:\/\/www.viva64.com\/ru\/b\/0377\/\">FreeBSD<\/a>. \u041e\u0448\u0438\u0431\u043a\u0443 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430: \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0441\u0435 \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u043a\u0440\u0443\u0436\u0430\u0442\u044c \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0442\u0430\u043a\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439: \u043f\u0440\u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 &#8216;x + 5&#8217; \u0432 &#8216;secs * 1000&#8217; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f &#8216;x + 5 * 1000&#8217;, \u0430 \u044d\u0442\u043e \u044f\u0432\u043d\u043e \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u043b \u0430\u0432\u0442\u043e\u0440.<\/p>\n<h2>\u0411\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0439 memset<\/h2>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V597\/\">V597<\/a> The compiler could delete the &#8216;memset&#8217; function call, which is used to flush &#8216;ps&#8217; buffer. The memset_s() function should be used to erase the private data. atom.c 1383  <\/p>\n<pre><code class=\"cpp\">int amdgpu_atom_asic_init(struct atom_context *ctx) {   int hwi = CU16(ctx-&gt;data_table + ATOM_DATA_FWI_PTR);   uint32_t ps[16];   int ret;    memset(ps, 0, 64);    ps[0] = cpu_to_le32(CU32(hwi + ATOM_FWI_DEFSCLK_PTR));   ps[1] = cpu_to_le32(CU32(hwi + ATOM_FWI_DEFMCLK_PTR));   if (!ps[0] || !ps[1])     return 1;    if (!CU16(ctx-&gt;cmd_table + 4 + 2 * ATOM_CMD_INIT))     return 1;   ret = amdgpu_atom_execute_table(ctx, ATOM_CMD_INIT, ps);   if (ret)     return ret;    memset(ps, 0, 64); \/\/ &lt;=    return ret; }<\/code><\/pre>\n<p>  \u041d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c <i>memset <\/i> \u043f\u0435\u0440\u0435\u0434 <i>return<\/i>: \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0443\u0432\u0438\u0434\u0435\u0432, \u0447\u0442\u043e \u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0432\u0438\u0434\u0438\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438), \u0443\u0434\u0430\u043b\u0438\u0442 \u0435\u0451. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u0442\u0435\u0440\u0435\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0432\u0430\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <i>memset_s<\/i> \u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0430\u043d\u0430\u043b\u043e\u0433.<\/p>\n<p>  \u042d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u043a\u0441\u0442\u0430\u0442\u0438 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c\u044e. \u041d\u0435 \u0437\u0430\u0442\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0437\u0430\u0442\u0451\u0440\u0442\u044b. \u0421 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 <a href=\"http:\/\/www.viva64.com\/ru\/w\/V597\/\">V597<\/a>. \u041a\u0441\u0442\u0430\u0442\u0438, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u0430\u044f \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c: <a href=\"http:\/\/www.viva64.com\/ru\/examples\/V597\/\">proof<\/a>.<\/p>\n<h2>\u041e\u043f\u0430\u0441\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 memcmp<\/h2>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 PVS-Studio:<\/b> <a href=\"http:\/\/www.viva64.com\/ru\/w\/V642\/\">V642<\/a> Saving the &#8216;memcmp&#8217; function result inside the &#8216;unsigned char&#8217; type variable is inappropriate. The significant bits could be lost breaking the program&#8217;s logic. host.c 1789  <\/p>\n<pre><code class=\"cpp\">static void power_control_timeout(unsigned long data) {   ....   u8 other = memcmp(requester-&gt;frame_rcvd.iaf.sas_addr,                     iphy-&gt;frame_rcvd.iaf.sas_addr,                     sizeof(requester-&gt;frame_rcvd.iaf.sas_addr));    if (other == 0) {     ....   }   .... }<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 <i>memcmp<\/i>, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438 \u043e \u043a\u0430\u043a\u043e\u043c-\u043b\u0438\u0431\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043d\u0435\u0442: \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0438\u043f\u0430. \u0418 \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 <i>-1<\/i>, <i>0<\/i> \u0438 <i>1<\/i>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430: \u043f\u0440\u0438 \u043f\u043e\u0442\u0435\u0440\u0435 \u0441\u0442\u0430\u0440\u0448\u0438\u0445 \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432 \u043c\u043b\u0430\u0434\u0448\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u043b\u044c. \u041f\u043e\u0445\u043e\u0436\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438\u0432\u0435\u043b\u0430 \u043a \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 <a href=\"http:\/\/seclists.org\/oss-sec\/2012\/q2\/493\">MySQL\/MariaDB<\/a>.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/db7\/f44\/06b\/db7f4406b3e045918e9a9a49cc570dff.png\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c, Linux \u2014 \u043e\u0447\u0435\u043d\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439, \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u041d\u0430\u0439\u0442\u0438 \u0432 \u043d\u0451\u043c \u043e\u0448\u0438\u0431\u043a\u0443, \u0434\u0430\u0436\u0435 \u0441\u0430\u043c\u0443\u044e \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e, \u2014 \u044d\u0442\u043e \u0443\u0436\u0435 \u043f\u043e\u0432\u043e\u0434 \u0434\u043b\u044f \u0433\u043e\u0440\u0434\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0436\u0435 \u0438 \u043f\u043e\u0432\u043e\u0434 \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0434\u043e \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0430\u043c\u043f\u043b\u0443\u0430 \u0446\u0435\u043d\u0435\u043d \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432 \u044d\u0442\u043e\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 PVS-Studio. \u0414\u043b\u044f \u043b\u0438\u043d\u0443\u043a\u0441\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0440\u0438\u0430\u043b-\u0432\u0435\u0440\u0441\u0438\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u043d\u0430\u043c \u043d\u0430 \u043f\u043e\u0447\u0442\u0443. \u0410 \u0434\u043b\u044f \u0441\u0432\u043e\u0438\u0445 \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c PVS-Studio \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e: \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 <a href=\"http:\/\/www.viva64.com\/ru\/b\/0457\/\">\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0451\u0439<\/a> \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439 \u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 <a href=\"https:\/\/github.com\/viva64\/how-to-use-pvs-studio-free\">how-to-use-pvs-studio-free<\/a>.<\/p>\n<p>  <a href=\"http:\/\/www.viva64.com\/en\/b\/0460\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/8d2\/41b\/5bf\/8d241b5bf34747169141ed7c1997143b.png\" \/><\/div>\n<p><\/a><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0441 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: Pavel Belikov. <a href=\"http:\/\/www.viva64.com\/en\/b\/0460\/\">Linux Kernel, tested by the Linux-version of PVS-Studio <\/a><\/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 \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441?<\/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, \u0432\u0435\u0440\u0441\u0438\u044f 2015<\/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<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=\"https:\/\/habrahabr.ru\/post\/317374\/\"> https:\/\/habrahabr.ru\/post\/317374\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fec\/53e\/cf2\/fec53ecf27f5499dbf1bb8068af5761a.png\"\/><\/p>\n<p>  \u0421 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0445\u043e\u0434\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0439 Linux-\u0432\u0435\u0440\u0441\u0438\u0438 PVS-Studio, \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u044f\u0434\u0440\u0430 Linux \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u043b\u0438\u0448\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u0430\u043c\u0438 \u0441\u043e \u0432\u0441\u0435\u0433\u043e \u043c\u0438\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439 \u0432 \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0444\u0435\u0440\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u043c \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430. \u041a\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 PVS-Studio \u0432 \u0442\u0430\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445?<\/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-282334","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282334","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=282334"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282334\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}