{"id":327661,"date":"2022-01-10T08:58:54","date_gmt":"2022-01-10T08:58:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=327661"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=327661","title":{"rendered":"<span>\u0422\u043e\u043f-10 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 C++ \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0437\u0430 2021 \u0433\u043e\u0434<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\" class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430 \u0443\u043b\u0438\u0446\u0435 \u043c\u043e\u0440\u043e\u0437, \u0451\u043b\u043a\u0430 \u043d\u0430\u0440\u044f\u0436\u0435\u043d\u0430, \u043c\u0430\u043d\u0434\u0430\u0440\u0438\u043d\u044b \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u044b. \u0414\u0435\u043b\u043e \u0438\u0434\u0451\u0442 \u043a \u041d\u043e\u0432\u043e\u043c\u0443 \u0433\u043e\u0434\u0443, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u2014 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 C++ \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c PVS-Studio \u0432 2021 \u0433\u043e\u0434\u0443.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"327\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f00\/0b9\/957\/f000b995782d4a56c97e1934e2b4f18f.png\" data-width=\"580\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0414\u0435\u0441\u044f\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430 \u0432 \u0446\u0438\u043a\u043b\u0435<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v533\/\">V533<\/a> [CWE-691] It is likely that a wrong variable is being incremented inside the &#8216;for&#8217; operator. Consider reviewing &#8216;i&#8217;. gskvulkanimage.c 721<\/p>\n<pre><code class=\"cpp\">void gsk_vulkan_image_upload_regions (GskVulkanImage    *self,                                  GskVulkanUploader *uploader,                                  guint              num_regions,                                  GskImageRegion    *regions) {   ....   for (int i = 0; i &lt; num_regions; i++)   {     m = mem + offset;     if (regions[i].stride == regions[i].width * 4)     {       memcpy (m, regions[i].data, regions[i].stride * regions[i].height);     }     else     {       for (gsize r = 0; r &lt; regions[i].height; i++)          \/\/ &lt;=         memcpy (m + r * regions[i].width * 4,                 regions[i].data + r * regions[i].stride, regions[i].width * 4);     }     ....   }   .... } <\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>r<\/em>, \u0430 <em>i<\/em>. \u0427\u0442\u043e-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u044f\u0441\u043d\u044f\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0437\u043e\u043b\u043e\u0442\u0430\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0430!<\/p>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0793\/\">\u0412\u044b\u044f\u0432\u043b\u044f\u0435\u043c \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 GTK 4 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PVS-Studio<\/a>&#171;.<\/p>\n<h3>\u0414\u0435\u0432\u044f\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 HTML!<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v735\/\">V735<\/a> Possibly an incorrect HTML. The &#171;&lt;\/body>&#187; closing tag was encountered, while the &#171;&lt;\/ul>&#187; tag was expected. qpixeltool.cpp 707<\/p>\n<pre><code class=\"cpp\">QString QPixelTool::aboutText() const {   const QList&lt;QScreen *> screens = QGuiApplication::screens();   const QScreen *windowScreen = windowHandle()->screen();    QString result;   QTextStream str(&amp;result);   str &lt;&lt; \"&lt;html>&lt;\/head>&lt;body>&lt;h2>Qt Pixeltool&lt;\/h2>&lt;p>Qt \" &lt;&lt; QT_VERSION_STR     &lt;&lt; \"&lt;\/p>&lt;p>Copyright (C) 2017 The Qt Company Ltd.&lt;\/p>&lt;h3>Screens&lt;\/h3>&lt;ul>\";   for (const QScreen *screen : screens)     str &lt;&lt; \"&lt;li>\" &lt;&lt; (screen == windowScreen ? \"* \" : \"  \")         &lt;&lt; screen &lt;&lt; \"&lt;\/li>\";   str &lt;&lt; \"&lt;ul>&lt;\/body>&lt;\/html>\";   return result; } <\/code><\/pre>\n<p>\u0412 PVS-Studio \u0435\u0441\u0442\u044c \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u0441\u0430\u043c \u043a\u043e\u0434, \u043d\u043e \u0438 \u0432\u044b\u0438\u0441\u043a\u0438\u0432\u0430\u044e\u0442 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u0445. \u0417\u0434\u0435\u0441\u044c \u043a\u0430\u043a \u0440\u0430\u0437 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0434\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0437\u0430\u0442\u043e \u044d\u0442\u0438\u043c \u043e\u043d \u0438 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u0435\u043d.<\/p>\n<p>\u0414\u0432\u0430\u0436\u0434\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0435\u0433 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430. \u042d\u0442\u043e \u044f\u0432\u043d\u0430\u044f \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0433 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u2013 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">str &lt;&lt; \"&lt;\/ul>&lt;\/body>&lt;\/html>\";<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0801\/\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u0442 \u043f\u0440\u0438\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u0438\u043b\u0438 77 \u0434\u0435\u0444\u0435\u043a\u0442\u043e\u0432 \u0432 Qt 6<\/a>&#171;.<\/p>\n<h3>\u0412\u043e\u0441\u044c\u043c\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u041e\u043f\u0430\u0441\u043d\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v634\/\">V634<\/a> The priority of the &#8216;*&#8217; operation is higher than that of the &#8216;&lt;&lt;&#8216; operation. It&#8217;s possible that parentheses should be used in the expression. bug34427.c 160<\/p>\n<pre><code class=\"cpp\">#define PM_EXP2(A) 1 &lt;&lt; A  int process_val(const u_int8_t *data, u_int32_t data_len,                                u_int32_t *retvalue, ....)  {   *retvalue = 0;   ....   \/* Now find the actual value *\/   for (; i &lt; data_len; i++) {     *retvalue += data[i] * PM_EXP2(8 * (data_len - i - 1));   }   return(0); } <\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 1, \u0430 \u0443\u0436\u0435 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u0441\u0434\u0432\u0438\u0433 \u043d\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445. \u041f\u043e\u0432\u0435\u0437\u043b\u043e, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <em>x * 1 &lt;&lt; y<\/em> \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e <em>x * (1  &lt;&lt; y)<\/em>.  \u0415\u0441\u043b\u0438 \u0441\u043b\u0435\u0432\u0430 \u0438\u043b\u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u043e\u044f\u0442\u044c <em>\/<\/em>,* %<em>,<\/em> +<em>,<\/em> -* \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c, \u0447\u0435\u043c \u0443 <em>&lt;&lt;,<\/em> \u043b\u0438\u0431\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u043e\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u043c\u0435\u043d\u044c\u0448\u0438\u043c, \u0447\u0435\u043c \u0443 <em>&lt;&lt;<\/em>, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0412\u0441\u0435\u0433\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441 \u0438 \u0435\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \u0422\u0430\u043a, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0431\u0443\u0434\u0435\u0442:<\/p>\n<pre><code class=\"cpp\">Define PM_EXP2(A) (1 &lt;&lt; (A))<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0812\/\">\u0421\u043a\u0430\u043d\u0435\u0440 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430 Snort \u043f\u043e\u0434 \u0441\u043a\u0430\u043d\u0435\u0440\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u043a\u043e\u0434\u0430 PVS-Studio<\/a>&#171;.<\/p>\n<h3>\u0421\u0435\u0434\u044c\u043c\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u043d\u044b \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0438 \u0434\u0435\u043b\u0438\u043c\u043e\u0435<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v1064\/\">V1064<\/a> The &#8216;gPEClockFrequencyInfo.bus_clock_rate_hz&#8217; operand of integer division is less than the &#8216;gPEClockFrequencyInfo.dec_clock_rate_hz&#8217; one. The result will always be zero. pe_identify_machine.c 72<\/p>\n<pre><code class=\"cpp\">void pe_identify_machine(__unused boot_args *args) {   ....   \/\/ Start with default values.   gPEClockFrequencyInfo.timebase_frequency_hz = 1000000000;   gPEClockFrequencyInfo.bus_frequency_hz      =  100000000;   ....   gPEClockFrequencyInfo.dec_clock_rate_hz =      gPEClockFrequencyInfo.timebase_frequency_hz;   gPEClockFrequencyInfo.bus_clock_rate_hz =    gPEClockFrequencyInfo.bus_frequency_hz;   ....    gPEClockFrequencyInfo.bus_to_dec_rate_den =     gPEClockFrequencyInfo.bus_clock_rate_hz \/     gPEClockFrequencyInfo.dec_clock_rate_hz; } <\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043b\u044f \u0438\u043c\u0435\u044e\u0442 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f:<\/p>\n<pre><code class=\"cpp\">extern clock_frequency_info_t gPEClockFrequencyInfo;  struct clock_frequency_info_t {   unsigned long bus_clock_rate_hz;   unsigned long dec_clock_rate_hz;   unsigned long bus_to_dec_rate_den;   unsigned long long bus_frequency_hz;   unsigned long timebase_frequency_hz;   .... }; <\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044e <em>gPEClockFrequencyInfo.bus_clock_rate_hz,<\/em> \u044f\u0432\u043b\u044f\u044e\u0449\u0435\u043c\u0443\u0441\u044f \u0434\u0435\u043b\u0438\u043c\u044b\u043c, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 100000000, \u0430 \u043f\u043e\u043b\u044e-\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044e <em>gPEClockFrequencyInfo.dec_clock_rate_hz<\/em> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1000000000. \u0414\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u0434\u0435\u0441\u044f\u0442\u044c \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u043b\u0438\u043c\u043e\u0433\u043e. \u0422\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0437\u0434\u0435\u0441\u044c \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438, \u043f\u043e\u043b\u0435 <em>gPEClockFrequencyInfo.bus_to_dec_rate_den<\/em> \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c 0.<\/p>\n<p>\u0421\u0443\u0434\u044f \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f <em>bus_to_dec_rate_den<\/em>, \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0438 \u0434\u0435\u043b\u0438\u043c\u043e\u0435 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u043d\u044b \u043c\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"580\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f78\/bee\/8d5\/f78bee8d532fc3a4eb7d06420af031be.png\" data-width=\"580\"\/><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0818\/\">\u042f\u0434\u0440\u043e macOS, \u0435\u0441\u0442\u044c \u043b\u0438 \u0447\u0435\u0440\u0432\u044f\u0447\u043a\u0438 \u0432 \u044d\u0442\u043e\u043c \u044f\u0431\u043b\u043e\u043a\u0435<\/a>&#171;.<\/p>\n<h3>\u0428\u0435\u0441\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0432\u044b\u0431\u043e\u0440\u0435 \u0442\u0438\u043f\u043e\u0432<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v610\/\">V610<\/a> Undefined behavior. Check the shift operator &#8216;>>=&#8217;. The right operand (&#8216;bitpos % 64&#8217; = [0..63]) is greater than or equal to the length in bits of the promoted left operand. master.c 354<\/p>\n<pre><code class=\"cpp\">\/\/ bitsperlong.h #ifdef CONFIG_64BIT #define BITS_PER_LONG 64 #else #define BITS_PER_LONG 32 #endif \/* CONFIG_64BIT *\/  \/\/ bits.h \/*  * Create a contiguous bitmask starting at bit position @l and ending at  * position @h. For example  * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.  *\/ #define __GENMASK(h, l) ....  \/\/ master.h #define I2C_MAX_ADDR      GENMASK(6, 0)  \/\/ master.c static enum i3c_addr_slot_status i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) {   int status, bitpos = addr * 2;                   \/\/ &lt;=    if (addr > I2C_MAX_ADDR)     return I3C_ADDR_SLOT_RSVD;    status = bus->addrslots[bitpos \/ BITS_PER_LONG];   status >>= bitpos % BITS_PER_LONG;               \/\/ &lt;=    return status &amp; I3C_ADDR_SLOT_STATUS_MASK; } <\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u0430\u043a\u0440\u043e\u0441 <em>BITS_PER_LONG<\/em> \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 64.<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>addr<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 [0..127]<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>addr >= 16<\/em>, \u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>status<\/em> \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u0430 \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0447\u0438\u0441\u043b\u043e \u0431\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u0442\u0438\u043f <em>int<\/em> (32 \u0431\u0438\u0442\u0430).<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0430\u0432\u0442\u043e\u0440 \u0445\u043e\u0442\u0435\u043b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u043b \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>bitpos<\/em> \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>status<\/em>. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u043d\u0435 \u0443\u0447\u0451\u043b, \u0447\u0442\u043e <em>int<\/em> \u0438\u043c\u0435\u0435\u0442 32-\u0431\u0438\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 64-\u0431\u0438\u0442\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0442\u0438\u043f\u0430 <em>long<\/em>.<\/p>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <em>status<\/em> \u0441 \u0442\u0438\u043f\u043e\u043c <em>long<\/em>.<\/p>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0858\/\">30 \u043b\u0435\u0442 \u044f\u0434\u0440\u0443 Linux: \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0442 PVS-Studio<\/a>&#171;. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0451 \u0435\u0449\u0451 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 \u2013 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \ud83d\ude42<\/p>\n<h3>\u041f\u044f\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043c\u0435\u0436\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u043f\u043e\u0442\u0435\u0440\u044f\u0432\u0448\u0438\u0439\u0441\u044f memset<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0433\u043e\u0434\u0443 \u0432 PVS-Studio \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043e\u0434\u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438 \u043d\u0443\u0436\u043d\u0430\u044f \u0444\u0438\u0447\u0430 \u2013 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0435\u0436\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0421++ \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0414\u0430\u043d\u043d\u043e\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <a href=\"https:\/\/github.com\/eranif\/codelite\">codelite<\/a> \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v597\/\">V597<\/a> The compiler could delete the &#8216;memset&#8217; function call, which is used to flush &#8216;current&#8217; object. The memset_s() function should be used to erase the private data. args.c 269<\/p>\n<pre><code class=\"cpp\">\/\/ args.c extern void eFree (void *const ptr);  extern void argDelete (Arguments* const current) {   Assert (current != NULL);   if (current->type ==  ARG_STRING  &amp;&amp;  current->item != NULL)     eFree (current->item);   memset (current, 0, sizeof (Arguments));  \/\/ &lt;=   eFree (current);                          \/\/ &lt;= }  \/\/ routines.c extern void eFree (void *const ptr) {   Assert (ptr != NULL);   free (ptr); } <\/code><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432 <em>memset<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <a href=\"https:\/\/godbolt.org\/z\/P95sW7TWs\">\u0443\u0434\u0430\u043b\u0451\u043d<\/a> \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 LTO (Link Time Optimization). \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/language\/as_if\">as-if<\/a>, \u0432\u0438\u0434\u0438\u0442, \u0447\u0442\u043e <em>eFree<\/em> \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e, \u0430 \u043b\u0438\u0448\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>free<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>\u0411\u0435\u0437 LTO \u0432\u044b\u0437\u043e\u0432 <em>eFree<\/em> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <em>memset<\/em> \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f.<\/p>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0851\/\">\u041c\u0435\u0436\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0421++ \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0432 PVS-Studio<\/a>&#171;.<\/p>\n<h3>\u0427\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 &amp;&amp; Unreal Engine<\/h3>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e PVS-Studio \u043d\u0430\u0447\u0430\u043b \u0435\u0449\u0451 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c Unreal Engine \u043f\u0440\u043e\u0435\u043a\u0442\u044b. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043c\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u0433\u0430, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u0436\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0436\u0435 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0435\u043c\u0443 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v547\/\">V547<\/a> Expression &#8216;m_trail == 0&#8217; is always false. unpack.hpp 699<\/p>\n<pre><code class=\"cpp\">std::size_t m_trail;  .... inline int context::execute(const char* data, std::size_t len,  std::size_t&amp; off) {   ....   case MSGPACK_CS_EXT_8: {                 uint8_t tmp;                 load&lt;uint8_t>(tmp, n);                 m_trail = tmp + 1;                 if(m_trail == 0) {                     unpack_ext(m_user, n, m_trail, obj);                     int ret = push_proc(obj, off);                     if (ret != 0) return ret;                 }                 else {                     m_cs = MSGPACK_ACS_EXT_VALUE;                     fixed_trail_again = true;                 }             } break;   .... } <\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>tmp<\/em>, \u0442\u0438\u043f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 <em>uint8_t<\/em>. \u0414\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0432\u043e\u0441\u044c\u043c\u044c\u044e \u0431\u0438\u0442\u0430\u043c\u0438 &#8212; <em>[0, 255]<\/em>. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0438\u0441\u0430\u043b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>tmp<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u043e <em>255<\/em>. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f <em>m_trail = tmp + 1<\/em> \u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u043d\u0435 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0439 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0446\u0438\u043a\u043b\u0438\u0447\u043d\u0430 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e, \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <em>tmp + 1<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <em>0<\/em>.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 <em>m_trail == 0<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 <em>false<\/em>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u043e\u0431\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043a\u0441\u0442\u0430\u0442\u0438, \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0448\u0435\u0439 \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0439 <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0892\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435. \u0412 \u043d\u0435\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 <em>usual arithmetic conversions<\/em>, \u0432 \u0445\u043e\u0434\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <em>tmp<\/em> \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0441\u044f <em>integral promotion<\/em>, \u0438 \u0435\u0451 \u0442\u0438\u043f \u0432 \u044d\u0442\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u0441\u044f \u0434\u043e \u0442\u0438\u043f\u0430 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430 <em>1<\/em>, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u043e <em>int<\/em>. \u0412 \u0438\u0442\u043e\u0433\u0435, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <em>tmp<\/em> \u0431\u0443\u0434\u0435\u0442 <em>255<\/em>, \u0432 \u0445\u043e\u0434\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 <em>256<\/em>. \u0422\u0438\u043f <em>int<\/em> \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 <em>m_trail == 0<\/em> \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u0430.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"580\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ef0\/072\/fad\/ef0072fad4aa4df2aed078cfcd40217f.png\" data-width=\"580\"\/><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0888\/\">\u041f\u0440\u043e\u043a\u0430\u0447\u043a\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 Unreal Engine 4 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0430\u0432\u0442\u043e\u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0430 Carla<\/a>&#171;.<\/p>\n<h3>\u0422\u0440\u0435\u0442\u044c\u0435 \u043c\u0435\u0441\u0442\u043e: \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u0442\u044b<\/h3>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 PVS-Studio \u0432\u044b\u0434\u0430\u043b \u0446\u0435\u043b\u044b\u0439 \u0431\u0443\u043a\u0435\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v547\/\">V547<\/a> [CWE-571] Expression &#8216;month&#8217; is always true. qdatetime.cpp 4907<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v560\/\">V560<\/a> [CWE-570] A part of conditional expression is always false: !month. qdatetime.cpp 4911<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v547\/\">V547<\/a> [CWE-571] Expression &#8216;month&#8217; is always true. qdatetime.cpp 4913<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v560\/\">V560<\/a> [CWE-570] A part of conditional expression is always false: !month. qdatetime.cpp 4921<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u043d\u043e\u043c\u0435\u0440 \u043c\u0435\u0441\u044f\u0446\u0430 \u043f\u043e \u0435\u0433\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0451\u043d\u043d\u043e\u043c\u0443 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"cpp\">static const char qt_shortMonthNames[][4] = {     \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",     \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" };  static int fromShortMonthName(QStringView monthName) {   for (unsigned int i = 0;        i &lt; sizeof(qt_shortMonthNames) \/ sizeof(qt_shortMonthNames[0]); ++i)   {     if (monthName == QLatin1String(qt_shortMonthNames[i], 3))       return i + 1;   }   return -1; } <\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u043f\u0435\u0445\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u043c\u0435\u0440 \u043c\u0435\u0441\u044f\u0446\u0430 (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0442 1 \u0434\u043e 12). \u0415\u0441\u043b\u0438 \u0438\u043c\u044f \u043c\u0435\u0441\u044f\u0446\u0430 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (-1). \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0.<\/p>\n<p>\u041d\u043e \u0442\u0430\u043c, \u0433\u0434\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0435\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043e \u043d\u0443\u043b\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430, \u0433\u0434\u0435 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>fromShortMonthName<\/em>:<\/p>\n<pre><code class=\"cpp\">QDateTime QDateTime::fromString(QStringView string, Qt::DateFormat format) {   ....   month = fromShortMonthName(parts.at(1));   if (month)     day = parts.at(2).toInt(&amp;ok);    \/\/ If failed, try day then month   if (!ok || !month || !day) {     month = fromShortMonthName(parts.at(2));     if (month) {       QStringView dayPart = parts.at(1);       if (dayPart.endsWith(u'.'))         day = dayPart.chopped(1).toInt(&amp;ok);     }   }   .... } <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u043e\u043c\u0435\u0440\u0430 \u043c\u0435\u0441\u044f\u0446\u0430 \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u043d\u0443\u043b\u044e \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0430.<\/p>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0801\/\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u0442 \u043f\u0440\u0438\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u0438\u043b\u0438 77 \u0434\u0435\u0444\u0435\u043a\u0442\u043e\u0432 \u0432 Qt 6<\/a>&#171;.<\/p>\n<h3>\u0412\u0442\u043e\u0440\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435\u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v726\/\">V726<\/a> An attempt to free memory containing the &#8216;wbuf&#8217; array by using the &#8216;free&#8217; function. This is incorrect as &#8216;wbuf&#8217; was created on stack. log.cpp 216<\/p>\n<pre><code class=\"cpp\">template&lt;typename T> static ALWAYS_INLINE void FormatLogMessageAndPrintW(....) {   ....   wchar_t wbuf[512];   wchar_t* wmessage_buf = wbuf;   ....   if (wmessage_buf != wbuf)   {     std::free(wbuf);   }   if (message_buf != buf)   {     std::free(message_buf);   }   .... } <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0441\u0442\u0435\u043a\u0435. \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0435 \u0431\u044b\u043b\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 \u043a\u0443\u0447\u0435, \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0442\u0430\u043a\u0436\u0435 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a s<em>td::free<\/em> \u0434\u043b\u044f \u0435\u0451 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u2013 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u0447\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u2013 \u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u044f. \u041d\u0435 \u0431\u0443\u0434\u0443 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u0438\u0442\u044c \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0880\/\">\u041a\u0430\u043a \u043e\u0434\u0438\u043d \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a PVS-Studio \u0437\u0430\u0449\u0438\u0449\u0430\u043b \u0431\u0430\u0433 \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/a>&#171;.<\/p>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u043c\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439, \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0881\/\">PVS-Studio \u0438\u0449\u0435\u0442 \u0431\u0430\u0433\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 DuckStation<\/a>&#171;.<\/p>\n<h3>\u041f\u0435\u0440\u0432\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043d\u0435\u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u0422\u0430\u043a \u0443\u0436 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0433\u043e\u0434\u0443 \u043c\u044b \u0441\u0430\u043c\u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u043b\u0438 \u043d\u0430 \u0442\u0435 \u0436\u0435 \u0433\u0440\u0430\u0431\u043b\u0438, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0443\u0431\u0435\u0440\u0435\u0447\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041c\u044b \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0435\u043c\u0441\u044f \u043e\u0431 \u044d\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e\u0442 \u0442\u0435\u043e\u0440\u0438\u044e \u2014 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430. \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443:<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v645\/\">V645<\/a> The &#8216;strncat&#8217; function call could lead to the &#8216;\u0430.consoleText&#8217; buffer overflow. The bounds should not contain the size of the buffer, but a number of characters it can hold.<\/p>\n<pre><code class=\"cpp\">struct A {   char consoleText[512]; };  void foo(A a) {   char inputBuffer[1024];   ....   strncat(a.consoleText, inputBuffer, sizeof(a.consoleText) \u2013                                       strlen(a.consoleText) - 5);   .... } <\/code><\/pre>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u0438 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u043c \u043d\u0435 \u0433\u0440\u043e\u0437\u0438\u0442. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">sizeof(a.consoleText) \u2013 strlen(a.consoleText) \u2013 5<\/code><\/pre>\n<p>\u0415\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e! \u0422\u0430\u043a\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 <em>strlen(a.consoleText) = 508<\/em>. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212;<em>size_t<\/em>.<\/p>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0842\/\">\u041e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u0438\u0437 \u0436\u0438\u0437\u043d\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 PVS-Studio, \u0438\u043b\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0442\u0440\u0451\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432<\/a>&#171;.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u042d\u0442\u043e\u0442 \u0433\u043e\u0434 \u0432\u044b\u0448\u0435\u043b \u043f\u043b\u043e\u0434\u043e\u0442\u0432\u043e\u0440\u043d\u044b\u043c \u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 C++ \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 \u0432 \u043d\u0438\u0445 \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0437\u043e\u0440\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0435 \u0432\u0438\u0434\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043c\u043e\u0435\u0433\u043e, \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 &#171;T\u043e\u043f-10&#8230;&#187;, \u043f\u043e\u0447\u0438\u0442\u0430\u0432 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/\">\u0431\u043b\u043e\u0433\u0430<\/a>.<\/p>\n<p>\u041f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e\u0434\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u0436\u0435 \u0441\u0442\u0430\u043b\u043e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0435\u0439, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0441\u0442\u0430\u0442\u044c\u0438 \u0441 \u0442\u043e\u043f-10 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 C++ \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043f\u0440\u043e\u0448\u043b\u044b\u0445 \u043b\u0435\u0442: <a href=\"https:\/\/pvs-studio.com\/ru\/b\/0483\/\">2016<\/a>, <a href=\"https:\/\/pvs-studio.com\/ru\/b\/0565\/\">2017<\/a>, <a href=\"https:\/\/pvs-studio.com\/ru\/b\/0619\/\">2018<\/a>, <a href=\"https:\/\/pvs-studio.com\/ru\/b\/0700\/\">2019<\/a>, <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0784\/\">2020<\/a>.<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/596975\/\"> https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/596975\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\" class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430 \u0443\u043b\u0438\u0446\u0435 \u043c\u043e\u0440\u043e\u0437, \u0451\u043b\u043a\u0430 \u043d\u0430\u0440\u044f\u0436\u0435\u043d\u0430, \u043c\u0430\u043d\u0434\u0430\u0440\u0438\u043d\u044b \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u044b. \u0414\u0435\u043b\u043e \u0438\u0434\u0451\u0442 \u043a \u041d\u043e\u0432\u043e\u043c\u0443 \u0433\u043e\u0434\u0443, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u2014 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 C++ \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c PVS-Studio \u0432 2021 \u0433\u043e\u0434\u0443.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0414\u0435\u0441\u044f\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430 \u0432 \u0446\u0438\u043a\u043b\u0435<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v533\/\">V533<\/a> [CWE-691] It is likely that a wrong variable is being incremented inside the &#8216;for&#8217; operator. Consider reviewing &#8216;i&#8217;. gskvulkanimage.c 721<\/p>\n<pre><code class=\"cpp\">void gsk_vulkan_image_upload_regions (GskVulkanImage    *self,                                  GskVulkanUploader *uploader,                                  guint              num_regions,                                  GskImageRegion    *regions) {   ....   for (int i = 0; i &lt; num_regions; i++)   {     m = mem + offset;     if (regions[i].stride == regions[i].width * 4)     {       memcpy (m, regions[i].data, regions[i].stride * regions[i].height);     }     else     {       for (gsize r = 0; r &lt; regions[i].height; i++)          \/\/ &lt;=         memcpy (m + r * regions[i].width * 4,                 regions[i].data + r * regions[i].stride, regions[i].width * 4);     }     ....   }   .... } <\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>r<\/em>, \u0430 <em>i<\/em>. \u0427\u0442\u043e-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u044f\u0441\u043d\u044f\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0437\u043e\u043b\u043e\u0442\u0430\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0430!<\/p>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0793\/\">\u0412\u044b\u044f\u0432\u043b\u044f\u0435\u043c \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 GTK 4 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PVS-Studio<\/a>&#171;.<\/p>\n<h3>\u0414\u0435\u0432\u044f\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 HTML!<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v735\/\">V735<\/a> Possibly an incorrect HTML. The &#171;&lt;\/body>&#187; closing tag was encountered, while the &#171;&lt;\/ul>&#187; tag was expected. qpixeltool.cpp 707<\/p>\n<pre><code class=\"cpp\">QString QPixelTool::aboutText() const {   const QList&lt;QScreen *> screens = QGuiApplication::screens();   const QScreen *windowScreen = windowHandle()->screen();    QString result;   QTextStream str(&amp;result);   str &lt;&lt; \"&lt;html>&lt;\/head>&lt;body>&lt;h2>Qt Pixeltool&lt;\/h2>&lt;p>Qt \" &lt;&lt; QT_VERSION_STR     &lt;&lt; \"&lt;\/p>&lt;p>Copyright (C) 2017 The Qt Company Ltd.&lt;\/p>&lt;h3>Screens&lt;\/h3>&lt;ul>\";   for (const QScreen *screen : screens)     str &lt;&lt; \"&lt;li>\" &lt;&lt; (screen == windowScreen ? \"* \" : \"  \")         &lt;&lt; screen &lt;&lt; \"&lt;\/li>\";   str &lt;&lt; \"&lt;ul>&lt;\/body>&lt;\/html>\";   return result; } <\/code><\/pre>\n<p>\u0412 PVS-Studio \u0435\u0441\u0442\u044c \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u0441\u0430\u043c \u043a\u043e\u0434, \u043d\u043e \u0438 \u0432\u044b\u0438\u0441\u043a\u0438\u0432\u0430\u044e\u0442 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u0445. \u0417\u0434\u0435\u0441\u044c \u043a\u0430\u043a \u0440\u0430\u0437 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0434\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0437\u0430\u0442\u043e \u044d\u0442\u0438\u043c \u043e\u043d \u0438 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u0435\u043d.<\/p>\n<p>\u0414\u0432\u0430\u0436\u0434\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0435\u0433 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430. \u042d\u0442\u043e \u044f\u0432\u043d\u0430\u044f \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0433 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u2013 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">str &lt;&lt; \"&lt;\/ul>&lt;\/body>&lt;\/html>\";<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0801\/\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u0442 \u043f\u0440\u0438\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u0438\u043b\u0438 77 \u0434\u0435\u0444\u0435\u043a\u0442\u043e\u0432 \u0432 Qt 6<\/a>&#171;.<\/p>\n<h3>\u0412\u043e\u0441\u044c\u043c\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u041e\u043f\u0430\u0441\u043d\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v634\/\">V634<\/a> The priority of the &#8216;*&#8217; operation is higher than that of the &#8216;&lt;&lt;&#8216; operation. It&#8217;s possible that parentheses should be used in the expression. bug34427.c 160<\/p>\n<pre><code class=\"cpp\">#define PM_EXP2(A) 1 &lt;&lt; A  int process_val(const u_int8_t *data, u_int32_t data_len,                                u_int32_t *retvalue, ....)  {   *retvalue = 0;   ....   \/* Now find the actual value *\/   for (; i &lt; data_len; i++) {     *retvalue += data[i] * PM_EXP2(8 * (data_len - i - 1));   }   return(0); } <\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 1, \u0430 \u0443\u0436\u0435 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u0441\u0434\u0432\u0438\u0433 \u043d\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445. \u041f\u043e\u0432\u0435\u0437\u043b\u043e, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <em>x * 1 &lt;&lt; y<\/em> \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e <em>x * (1  &lt;&lt; y)<\/em>.  \u0415\u0441\u043b\u0438 \u0441\u043b\u0435\u0432\u0430 \u0438\u043b\u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u043e\u044f\u0442\u044c <em>\/<\/em>,* %<em>,<\/em> +<em>,<\/em> -* \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c, \u0447\u0435\u043c \u0443 <em>&lt;&lt;,<\/em> \u043b\u0438\u0431\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u043e\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u043c\u0435\u043d\u044c\u0448\u0438\u043c, \u0447\u0435\u043c \u0443 <em>&lt;&lt;<\/em>, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0412\u0441\u0435\u0433\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441 \u0438 \u0435\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \u0422\u0430\u043a, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0431\u0443\u0434\u0435\u0442:<\/p>\n<pre><code class=\"cpp\">Define PM_EXP2(A) (1 &lt;&lt; (A))<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0812\/\">\u0421\u043a\u0430\u043d\u0435\u0440 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430 Snort \u043f\u043e\u0434 \u0441\u043a\u0430\u043d\u0435\u0440\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u043a\u043e\u0434\u0430 PVS-Studio<\/a>&#171;.<\/p>\n<h3>\u0421\u0435\u0434\u044c\u043c\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u043d\u044b \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0438 \u0434\u0435\u043b\u0438\u043c\u043e\u0435<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v1064\/\">V1064<\/a> The &#8216;gPEClockFrequencyInfo.bus_clock_rate_hz&#8217; operand of integer division is less than the &#8216;gPEClockFrequencyInfo.dec_clock_rate_hz&#8217; one. The result will always be zero. pe_identify_machine.c 72<\/p>\n<pre><code class=\"cpp\">void pe_identify_machine(__unused boot_args *args) {   ....   \/\/ Start with default values.   gPEClockFrequencyInfo.timebase_frequency_hz = 1000000000;   gPEClockFrequencyInfo.bus_frequency_hz      =  100000000;   ....   gPEClockFrequencyInfo.dec_clock_rate_hz =      gPEClockFrequencyInfo.timebase_frequency_hz;   gPEClockFrequencyInfo.bus_clock_rate_hz =    gPEClockFrequencyInfo.bus_frequency_hz;   ....    gPEClockFrequencyInfo.bus_to_dec_rate_den =     gPEClockFrequencyInfo.bus_clock_rate_hz \/     gPEClockFrequencyInfo.dec_clock_rate_hz; } <\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043b\u044f \u0438\u043c\u0435\u044e\u0442 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f:<\/p>\n<pre><code class=\"cpp\">extern clock_frequency_info_t gPEClockFrequencyInfo;  struct clock_frequency_info_t {   unsigned long bus_clock_rate_hz;   unsigned long dec_clock_rate_hz;   unsigned long bus_to_dec_rate_den;   unsigned long long bus_frequency_hz;   unsigned long timebase_frequency_hz;   .... }; <\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044e <em>gPEClockFrequencyInfo.bus_clock_rate_hz,<\/em> \u044f\u0432\u043b\u044f\u044e\u0449\u0435\u043c\u0443\u0441\u044f \u0434\u0435\u043b\u0438\u043c\u044b\u043c, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 100000000, \u0430 \u043f\u043e\u043b\u044e-\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044e <em>gPEClockFrequencyInfo.dec_clock_rate_hz<\/em> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1000000000. \u0414\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u0434\u0435\u0441\u044f\u0442\u044c \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u043b\u0438\u043c\u043e\u0433\u043e. \u0422\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0437\u0434\u0435\u0441\u044c \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438, \u043f\u043e\u043b\u0435 <em>gPEClockFrequencyInfo.bus_to_dec_rate_den<\/em> \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c 0.<\/p>\n<p>\u0421\u0443\u0434\u044f \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f <em>bus_to_dec_rate_den<\/em>, \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0438 \u0434\u0435\u043b\u0438\u043c\u043e\u0435 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u043d\u044b \u043c\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0818\/\">\u042f\u0434\u0440\u043e macOS, \u0435\u0441\u0442\u044c \u043b\u0438 \u0447\u0435\u0440\u0432\u044f\u0447\u043a\u0438 \u0432 \u044d\u0442\u043e\u043c \u044f\u0431\u043b\u043e\u043a\u0435<\/a>&#171;.<\/p>\n<h3>\u0428\u0435\u0441\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0432\u044b\u0431\u043e\u0440\u0435 \u0442\u0438\u043f\u043e\u0432<\/h3>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v610\/\">V610<\/a> Undefined behavior. Check the shift operator &#8216;>>=&#8217;. The right operand (&#8216;bitpos % 64&#8217; = [0..63]) is greater than or equal to the length in bits of the promoted left operand. master.c 354<\/p>\n<pre><code class=\"cpp\">\/\/ bitsperlong.h #ifdef CONFIG_64BIT #define BITS_PER_LONG 64 #else #define BITS_PER_LONG 32 #endif \/* CONFIG_64BIT *\/  \/\/ bits.h \/*  * Create a contiguous bitmask starting at bit position @l and ending at  * position @h. For example  * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.  *\/ #define __GENMASK(h, l) ....  \/\/ master.h #define I2C_MAX_ADDR      GENMASK(6, 0)  \/\/ master.c static enum i3c_addr_slot_status i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) {   int status, bitpos = addr * 2;                   \/\/ &lt;=    if (addr > I2C_MAX_ADDR)     return I3C_ADDR_SLOT_RSVD;    status = bus->addrslots[bitpos \/ BITS_PER_LONG];   status >>= bitpos % BITS_PER_LONG;               \/\/ &lt;=    return status &amp; I3C_ADDR_SLOT_STATUS_MASK; } <\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u0430\u043a\u0440\u043e\u0441 <em>BITS_PER_LONG<\/em> \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 64.<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>addr<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 [0..127]<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>addr >= 16<\/em>, \u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>status<\/em> \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u0430 \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0447\u0438\u0441\u043b\u043e \u0431\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u0442\u0438\u043f <em>int<\/em> (32 \u0431\u0438\u0442\u0430).<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0430\u0432\u0442\u043e\u0440 \u0445\u043e\u0442\u0435\u043b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u043b \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>bitpos<\/em> \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>status<\/em>. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u043d\u0435 \u0443\u0447\u0451\u043b, \u0447\u0442\u043e <em>int<\/em> \u0438\u043c\u0435\u0435\u0442 32-\u0431\u0438\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0430 64-\u0431\u0438\u0442\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0442\u0438\u043f\u0430 <em>long<\/em>.<\/p>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <em>status<\/em> \u0441 \u0442\u0438\u043f\u043e\u043c <em>long<\/em>.<\/p>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0858\/\">30 \u043b\u0435\u0442 \u044f\u0434\u0440\u0443 Linux: \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0442 PVS-Studio<\/a>&#171;. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0451 \u0435\u0449\u0451 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 \u2013 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \ud83d\ude42<\/p>\n<h3>\u041f\u044f\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u043c\u0435\u0436\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u043f\u043e\u0442\u0435\u0440\u044f\u0432\u0448\u0438\u0439\u0441\u044f memset<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0433\u043e\u0434\u0443 \u0432 PVS-Studio \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043e\u0434\u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438 \u043d\u0443\u0436\u043d\u0430\u044f \u0444\u0438\u0447\u0430 \u2013 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0435\u0436\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0421++ \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0414\u0430\u043d\u043d\u043e\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <a href=\"https:\/\/github.com\/eranif\/codelite\">codelite<\/a> \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v597\/\">V597<\/a> The compiler could delete the &#8216;memset&#8217; function call, which is used to flush &#8216;current&#8217; object. The memset_s() function should be used to erase the private data. args.c 269<\/p>\n<pre><code class=\"cpp\">\/\/ args.c extern void eFree (void *const ptr);  extern void argDelete (Arguments* const current) {   Assert (current != NULL);   if (current->type ==  ARG_STRING  &amp;&amp;  current->item != NULL)     eFree (current->item);   memset (current, 0, sizeof (Arguments));  \/\/ &lt;=   eFree (current);                          \/\/ &lt;= }  \/\/ routines.c extern void eFree (void *const ptr) {   Assert (ptr != NULL);   free (ptr); } <\/code><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432 <em>memset<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <a href=\"https:\/\/godbolt.org\/z\/P95sW7TWs\">\u0443\u0434\u0430\u043b\u0451\u043d<\/a> \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 LTO (Link Time Optimization). \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/language\/as_if\">as-if<\/a>, \u0432\u0438\u0434\u0438\u0442, \u0447\u0442\u043e <em>eFree<\/em> \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e, \u0430 \u043b\u0438\u0448\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>free<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>\u0411\u0435\u0437 LTO \u0432\u044b\u0437\u043e\u0432 <em>eFree<\/em> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <em>memset<\/em> \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f.<\/p>\n<p>\u042d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0448\u043b\u0430 \u0432 \u0442\u043e\u043f \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: &#171;<a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0851\/\">\u041c\u0435\u0436\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0421++ \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0432 PVS-Studio<\/a>&#171;.<\/p>\n<h3>\u0427\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 &amp;&amp; Unreal Engine<\/h3>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e PVS-Studio \u043d\u0430\u0447\u0430\u043b \u0435\u0449\u0451 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c Unreal Engine \u043f\u0440\u043e\u0435\u043a\u0442\u044b. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043c\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u0433\u0430, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u0436\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0436\u0435 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0435\u043c\u0443 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v547\/\">V547<\/a> Expression &#8216;m_trail == 0&#8217; is always false. unpack.hpp 699<\/p>\n<pre><code class=\"cpp\">std::size_t m_trail;  .... inline int context::execute(const char* data, std::size_t len,  std::size_t&amp; off) {   ....   case MSGPACK_CS_EXT_8: {                 uint8_t tmp;                 load&lt;uint8_t>(tmp, n);                 m_trail = tmp + 1;                 if(m_trail == 0) {                     unpack_ext(m_user, n, m_trail, obj);                     int ret = push_proc(obj, off);                     if (ret != 0) return ret;                 }                 else {                     m_cs = MSGPACK_ACS_EXT_VALUE;                     fixed_trail_again = true;                 }             } break;   .... } <\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>tmp<\/em>, \u0442\u0438\u043f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 <em>uint8_t<\/em>. \u0414\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0432\u043e\u0441\u044c\u043c\u044c\u044e \u0431\u0438\u0442\u0430\u043c\u0438 &#8212; <em>[0, 255]<\/em>. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0438\u0441\u0430\u043b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>tmp<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u043e <em>255<\/em>. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f <em>m_trail = tmp + 1<\/em> \u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u043d\u0435 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0439 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0446\u0438\u043a\u043b\u0438\u0447\u043d\u0430 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e, \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <em>tmp + 1<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <em>0<\/em>.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 <em>m_trai<\/em><\/p>\n<\/div>\n<\/div>\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-327661","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/327661","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=327661"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/327661\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=327661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=327661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=327661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}