Examples of errors detected by the V706 diagnostic.


V706. Suspicious division: sizeof(X) / Value. Size of every element in X array does not equal to divisor.


Haiku Operation System

V706 Suspicious division: sizeof (kBaudrates) / sizeof (char *). Size of every element in 'kBaudrates' array does not equal to divisor. SerialWindow.cpp 162


const int SerialWindow::kBaudrates[] = { 50, 75, 110, .... };

SerialWindow::SerialWindow() : ....
{
  ....
  for(int i = sizeof(kBaudrates) / sizeof(char*);          // <=
        --i >= 0;)
  {
    message = new BMessage(kMsgSettings);
    message->AddInt32("baudrate", kBaudrateConstants[i]);

    char buffer[7];
    sprintf(buffer, "%d", kBaudrates[i]);                  // <=
    BMenuItem* item = new BMenuItem(buffer, message);

    fBaudrateMenu->AddItem(item);
  }
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;
We use cookies for the analysis of events to improve our content and make user interaction more convenient. By continuing the view of our web-pages you accept the terms of using these files. You can find out more about cookie-files and privacy policy or close the notification, by clicking on the button. Learn More →
Do not show