Examples of errors detected by the V792 diagnostic


V792. The function located to the right of the '|' and '&' operators will be called regardless of the value of the left operand. Consider using '||' and '&&' instead.


Stellarium

V792 The 'toBool' function located to the right of the operator '&' will be called regardless of the value of the left operand. Perhaps, it is better to use '&&'. LandscapeMgr.cpp 782


void LandscapeMgr::onTargetLocationChanged(StelLocation loc)
{
  ....
  if (pl && flagEnvironmentAutoEnabling)
  {
    QSettings* conf = StelApp::getInstance().getSettings();
    setFlagAtmosphere(pl->hasAtmosphere()
                    & conf->value("landscape/flag_atmosphere", true).toBool());
    setFlagFog(pl->hasAtmosphere()
             & conf->value("landscape/flag_fog", true).toBool());
    setFlagLandscape(true);
  }
  ....
}

Similar errors can be found in some other places:

  • V792 The 'toBool' function located to the right of the operator '&' will be called regardless of the value of the left operand. Perhaps, it is better to use '&&'. LandscapeMgr.cpp 783

Haiku Operation System

V792 The 'SetDecoratorSettings' function located to the right of the operator '|' will be called regardless of the value of the left operand. Perhaps, it is better to use '||'. DesktopListener.cpp 324


class DesktopListener : public DoublyLinkedListLinkImpl<DesktopListener> {
public:
 ....
 virtual bool SetDecoratorSettings(Window* window,
         const BMessage& settings) = 0;
 ....
};

bool
DesktopObservable::SetDecoratorSettings(Window* window,
  const BMessage& settings)
{
  if (fWeAreInvoking)
    return false;
  InvokeGuard invokeGuard(fWeAreInvoking);

  bool changed = false;
  for (DesktopListener* listener = fDesktopListenerList.First();
    listener != NULL; listener = fDesktopListenerList.GetNext(listener))
    changed = changed | listener->SetDecoratorSettings(window, settings);

  return changed;
}


Bugs Found

Checked Projects
355
Collected Errors
13 303