Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam

Webinar: Evaluation - 05.12

>
>
>
Examples of errors detected by the V524…

Examples of errors detected by the V524 diagnostic

V524. It is suspicious that the body of 'Foo_1' function is fully equivalent to the body of 'Foo_2' function.


TortoiseSVN

V524 It is odd that the 'GetDbgHelpVersion' function is fully equivalent to the 'GetImageHlpVersion' function (SymbolEngine.h, line 98). symbolengine.h 105


BOOL GetImageHlpVersion(DWORD &dwMS, DWORD &dwLS)
{
  return(GetInMemoryFileVersion(("DBGHELP.DLL"),
                                dwMS,
                                dwLS)) ;
}

BOOL GetDbgHelpVersion(DWORD &dwMS, DWORD &dwLS)
{
  return(GetInMemoryFileVersion(("DBGHELP.DLL"),
                                dwMS,
                                dwLS)) ;
}

Nmap Security Scanner

V524 It is odd that the body of 'stopRuntime' function is fully equivalent to the body of 'startRuntime' function (stats.cc, line 274). nping stats.cc 280


class NpingTimer {
  ....
  int start();
  int stop();
  ....
};

int NpingStats::startRuntime(){
  this->run_timer.start();
  return OP_SUCCESS;
}

int NpingStats::stopRuntime(){
  this->run_timer.start();
  return OP_SUCCESS;
}

Most likely this is what should be written in stopRuntime: this->run_timer.stop();


LLVM/Clang

V524 It is odd that the body of 'clearTopDownPointers' function is fully equivalent to the body of 'clearBottomUpPointers' function (ObjCARC.cpp, line 1318). LLVMScalarOpts objcarc.cpp 1322


MapTy PerPtrTopDown;
MapTy PerPtrBottomUp;

void clearBottomUpPointers() {
  PerPtrTopDown.clear();
}

void clearTopDownPointers() {
  PerPtrTopDown.clear();
}

Most likely this is what should be written in clearBottomUpPointers(): PerPtrBottomUp.clear();


Blender

V524 It is odd that the body of 'uiLayoutGetScaleY' function is fully equivalent to the body of 'uiLayoutGetScaleX' function (interface_layout.c, line 2410). bf_editor_interface interface_layout.c 2415


float uiLayoutGetScaleX(uiLayout *layout)
{
  return layout->scale[0];
}

float uiLayoutGetScaleY(uiLayout *layout)
{
  return layout->scale[0];
}

Most likely this is what should be written in uiLayoutGetScaleY(): layout->scale[1];


MAME

V524 It is odd that the body of 'max_opcode_bytes' function is fully equivalent to the body of 'min_opcode_bytes' function (debugcpu.h, line 150). debugcpu.h 151


class device_disasm_interface : public device_interface
{
  ....
public:
  UINT32 min_opcode_bytes() const
   { return disasm_min_opcode_bytes(); }
  UINT32 max_opcode_bytes() const
   { return disasm_max_opcode_bytes(); }
  ....
}

class device_debug
{
  device_disasm_interface *m_disasm;
  ....
  int min_opcode_bytes() const
    {
      return (m_disasm != NULL) ?
        m_disasm->max_opcode_bytes() : 1;
    }
  int max_opcode_bytes() const
    {
      return (m_disasm != NULL) ?
        m_disasm->max_opcode_bytes() : 1;
    }
}

OpenCV

V524 It is odd that the body of 'augAssignXor' function is fully equivalent to the body of 'augAssignDivide' function (matop.cpp, line 294). matop.cpp 318


void MatOp::augAssignAnd(const MatExpr& expr, Mat& m) const
{
    Mat temp;
    expr.op->assign(expr, temp);
    m &= temp;
}

void MatOp::augAssignOr(const MatExpr& expr, Mat& m) const
{
    Mat temp;
    expr.op->assign(expr, temp);
    m |= temp;
}

void MatOp::augAssignDivide(const MatExpr& expr, Mat& m) const
{
    Mat temp;
    expr.op->assign(expr, temp);
    m /= temp;
}

void MatOp::augAssignXor(const MatExpr& expr, Mat& m) const
{
    Mat temp;
    expr.op->assign(expr, temp);
    m /= temp;
}

Trans-Proteomic Pipeline

V524 It is odd that the body of '--' function is fully equivalent to the body of '++' function. charindexedvector.hpp 81


CharIndexedVectorIterator& operator++()
{ // preincrement
  ++m_itr;
  return (*this);
}

CharIndexedVectorIterator& operator--()
{  // predecrement
  ++m_itr;
  return (*this);
}

Similar errors can be found in some other places:

  • V524 It is odd that the body of '--' function is fully equivalent to the body of '++' function. charindexedvector.hpp 87
  • V524 It is odd that the body of '--' function is fully equivalent to the body of '++' function. charindexedvector.hpp 159
  • V524 It is odd that the body of '--' function is fully equivalent to the body of '++' function. charindexedvector.hpp 165

SeqAn

V524 It is odd that the body of '_calcIntervalTreeNodeCenterRight' function is fully equivalent to the body of '_calcIntervalTreeNodeCenterLeft' function. misc_interval_tree.h 1216


template<typename TIntervals, typename TValue>
TValue
_calcIntervalTreeNodeCenterLeft(TIntervals & intervals,
   TValue &, TValue &, Tag<TagRandomCenter_> const)
{
  SEQAN_CHECKPOINT
  TValue rand_index = rand()%length(intervals);
  return (rightBoundary(*value(intervals,rand_index))+
          leftBoundary(*value(intervals,rand_index)))
         /(TValue)2.0;
}

template<typename TIntervals, typename TValue>
TValue
_calcIntervalTreeNodeCenterRight(TIntervals & intervals,
  TValue &, TValue &, Tag<TagRandomCenter_> const)
{
  SEQAN_CHECKPOINT
  TValue rand_index = rand()%length(intervals);
  return (rightBoundary(*value(intervals,rand_index))+
          leftBoundary(*value(intervals,rand_index)))
         /(TValue)2.0;
}

Geant4 software

V524 It is odd that the body of 'GetH2Xmax' function is fully equivalent to the body of 'GetH2Xmin' function. _G4analysis-archive g4csvanalysismanager.cc 933


G4double G4CsvAnalysisManager::GetH2Xmin(G4int /*id*/) const
{
  ExceptionForHistograms("GetH2Xmin");
  return 0;
}

G4double G4CsvAnalysisManager::GetH2Xmax(G4int /*id*/) const
{
  ExceptionForHistograms("GetH2Xmin");
  return 0;
}

Chromium

V524 It is odd that the body of 'end' function is fully equivalent to the body of 'begin' function. event_packet.h 36


class CONTENT_EXPORT EventPacket {
  ....
  InputEvents::const_iterator begin() const
    { return events_.end(); }
  InputEvents::const_iterator end() const
    { return events_.end(); }
  ....
protected:
  InputEvents events_;
  ....
};

OpenMW

V524 It is odd that the body of 'getWriteSourceCache' function is fully equivalent to the body of 'getReadSourceCache' function. components factory.hpp 209


class Factory
{
  ....
  bool getReadSourceCache() { return mReadSourceCache; }
  bool getWriteSourceCache() { return mReadSourceCache; }
  ....
  bool mReadSourceCache;
  bool mWriteSourceCache;
  ....
};

Spring Engine

V524 It is odd that the body of '-' function is fully equivalent to the body of '+' function. assimp%engine-headless%engine-legacy types.h 183


/** Component-wise addition */
aiColor3D operator+(const aiColor3D& c) const {
  return aiColor3D(r+c.r,g+c.g,b+c.b);
}

/** Component-wise subtraction */
aiColor3D operator-(const aiColor3D& c) const {
  return aiColor3D(r+c.r,g+c.g,b+c.b);
}

Spring Engine

V524 It is odd that the body of '>' function is fully equivalent to the body of '<' function. assimp 3dshelper.h 470


bool operator < (const aiFloatKey& o) const
  {return mTime < o.mTime;}

bool operator > (const aiFloatKey& o) const
  {return mTime < o.mTime;}

The GTK+ Project

V524 It is odd that the body of 'gtk_mirror_bin_get_preferred_height' function is fully equivalent to the body of 'gtk_mirror_bin_get_preferred_width' function. offscreen_window2.c 340


static void
gtk_mirror_bin_get_preferred_width (GtkWidget *widget,
                                    gint      *minimum,
                                    gint      *natural)
{
  GtkRequisition requisition;
  gtk_mirror_bin_size_request (widget, &requisition);
  *minimum = *natural = requisition.width;
}

static void
gtk_mirror_bin_get_preferred_height (GtkWidget *widget,
                                     gint      *minimum,
                                     gint      *natural)
{
  GtkRequisition requisition;

  gtk_mirror_bin_size_request (widget, &requisition);

  *minimum = *natural = requisition.width;
}

The GTK+ Project

V524 It is odd that the body of 'gtk_hsv_get_preferred_height' function is fully equivalent to the body of 'gtk_hsv_get_preferred_width' function. gtkhsv.c 310


static void
gtk_hsv_get_preferred_width (GtkWidget *widget,
                             gint      *minimum,
                             gint      *natural)
{
  GtkHSV *hsv = GTK_HSV (widget);
  GtkHSVPrivate *priv = hsv->priv;
  gint focus_width;
  gint focus_pad;

  gtk_widget_style_get (widget,
                        "focus-line-width", &focus_width,
                        "focus-padding", &focus_pad,
                        NULL);

  *minimum = priv->size + 2 * (focus_width + focus_pad);
  *natural = priv->size + 2 * (focus_width + focus_pad);
}

static void
gtk_hsv_get_preferred_height (GtkWidget *widget,
                              gint      *minimum,
                              gint      *natural)
{
  GtkHSV *hsv = GTK_HSV (widget);
  GtkHSVPrivate *priv = hsv->priv;
  gint focus_width;
  gint focus_pad;

  gtk_widget_style_get (widget,
                        "focus-line-width", &focus_width,
                        "focus-padding", &focus_pad,
                        NULL);

  *minimum = priv->size + 2 * (focus_width + focus_pad);
  *natural = priv->size + 2 * (focus_width + focus_pad);
}

Open X-Ray Engine

V524 It is odd that the body of 'width' function is fully equivalent to the body of 'height' function. tpixel.h 1090


class RGBAMipMappedCubeMap
{
  ....
  size_t height() const
  {
    return cubeFaces[0].height();
  }

  size_t width() const
  {
    return cubeFaces[0].height();
  }
  ....
};

Tizen

V524 It is odd that the body of '_compare_by_frequency' function is fully equivalent to the body of '_compare_by_name' function. setting-storage-applications-utils.c 79


typedef struct {
  char *id;
  char *size_str;
  char *name;
  char *l_icon;
  unsigned long long size;
  int total_size;
  time_t added_time;
  bool is_removable;
  Setting_GenGroupItem_Data *data;
  SettingStorage *ad;
  Ecore_Timer *size_timer;
} Node_Info;

int _compare_by_name(const void *data1, const void *data2)
{
  const Node_Info *d1 = data1;
  const Node_Info *d2 = data2;

  if (!d1)
    return -1;
  if (!d2)
    return 1;

  return(strcmp(d1->name, d2->name));
}

int _compare_by_frequency(const void *data1, const void *data2)
{
  const Node_Info *d1 = data1;
  const Node_Info *d2 = data2;

  if (!d1)
    return -1;
  if (!d2)
    return 1;

  return(strcmp(d1->name, d2->name));
}

MuseScore

V524 It is odd that the body of 'downLine' function is fully equivalent to the body of 'upLine' function. rest.cpp 667


int Rest::upLine() const
{
  qreal _spatium = spatium();
  return lrint((pos().y() + bbox().top() +
    _spatium) * 2 / _spatium);
}

int Rest::downLine() const
{
  qreal _spatium = spatium();
  return lrint((pos().y() + bbox().top() +
    _spatium) * 2 / _spatium);
}

FreeRDP

V524 It is odd that the body of 'trio_index_last' function is fully equivalent to the body of 'trio_index' function. triostr.c 933


/**
   Find first occurrence of a character in a string.
   ....
 */
TRIO_PUBLIC_STRING char *
trio_index
TRIO_ARGS2((string, character),
     TRIO_CONST char *string,
     int character)
{
  assert(string);
  return strchr(string, character);
}

/**
   Find last occurrence of a character in a string.
   ....
 */
TRIO_PUBLIC_STRING char *
trio_index_last
TRIO_ARGS2((string, character),
     TRIO_CONST char *string,
     int character)
{
  assert(string);
  return strchr(string, character);
}

EAStdC

V524 It is odd that the body of '>>' function is fully equivalent to the body of '<<' function. EAFixedPoint.h 287


template <class  T,
  int  upShiftInt, int downShiftInt,
  int  upMulInt,   int downDivInt>

struct FPTemplate
{
  ....
  FPTemplate operator<<(int numBits) const { return value << numBits; }
  FPTemplate operator>>(int numBits) const { return value << numBits; }

  FPTemplate& operator<<=(int numBits) { value <<= numBits; return *this;}
  FPTemplate& operator>>=(int numBits) { value >>= numBits; return *this;}
  ....
}

Heawei Ark Compiler

V524 It is odd that the body of '-' function is fully equivalent to the body of '+' function. mpl_number.h 158


template <typename T, typename Tag>
inline Number<T, Tag> operator+(const Number<T, Tag> &lhs,
                                const Number<T, Tag> &rhs) {
  return Number<T, Tag>(lhs.get() + rhs.get());
}

template <typename T, typename Tag>
inline Number<T, Tag> operator-(const Number<T, Tag> &lhs,
                                const Number<T, Tag> &rhs) {
  return Number<T, Tag>(lhs.get() + rhs.get());
}

Similar errors can be found in some other places:

  • V524 It is odd that the body of '-' function is fully equivalent to the body of '+' function. mpl_number.h 233
  • V524 It is odd that the body of '-' function is fully equivalent to the body of '+' function. mpl_number.h 238

Newton Game Dynamics

V524 It is odd that the body of 'EnabledAxis1' function is fully equivalent to the body of 'EnabledAxis0' function. dCustomDoubleHingeActuator.cpp 88


void dCustomDoubleHingeActuator::EnabledAxis0(bool state)
{
  m_axis0Enable = state;  <=
}
void dCustomDoubleHingeActuator::EnabledAxis1(bool state)
{
  m_axis0Enable = state;  <=
}

Command & Conquer

V524 It is odd that the body of 'Mono_Y' function is fully equivalent to the body of 'Mono_X' function. MONOC.CPP 753


class MonoClass {
  ....
  int Get_X(void) const {return X;};
  int Get_Y(void) const {return Y;};
  ....
}

int Mono_X(void)
{
  if (MonoClass::Is_Enabled()) {
    MonoClass *mono = MonoClass::Get_Current();
    if (!mono) {
      mono = new MonoClass();
      mono->View();
    }
    return(short)mono->Get_X();                  // <=
  }
  return(0);
}

int Mono_Y(void)
{
  if (MonoClass::Is_Enabled()) {
    MonoClass *mono = MonoClass::Get_Current();
    if (!mono) {
      mono = new MonoClass();
      mono->View();
    }
    return(short)mono->Get_X();                  // <= Get_Y() ?
  }
  return(0);
}

Similar errors can be found in some other places:

  • V524 It is odd that the body of 'Mono_Y' function is fully equivalent to the body of 'Mono_X' function. MONOC.CPP 1083

Indicators

V524 It is odd that the body of 'move_down' function is fully equivalent to the body of 'move_up' function. indicators.hpp 983


static inline void move_up(int lines) { move(0, -lines); }
static inline void move_down(int lines) { move(0, -lines); }    // <=
static inline void move_right(int cols) { move(cols, 0); }
static inline void move_left(int cols) { move(-cols, 0); }

Qt

V524 It is odd that the body of '<=' function is fully equivalent to the body of '<' function. qjsonobject.h 155


class Q_CORE_EXPORT QJsonObject
{
  ....
  bool operator<(const iterator& other) const
  { Q_ASSERT(item.o == other.item.o); return item.index < other.item.index; }
  bool operator<=(const iterator& other) const
  { Q_ASSERT(item.o == other.item.o); return item.index < other.item.index; }
  ....
}

MuseScore

V524 It is odd that the body of 'downLine' function is fully equivalent to the body of 'upLine' function. rest.cpp 718


int Rest::upLine() const
{
    qreal _spatium = spatium();
    return lrint((pos().y() + bbox().top() + _spatium) * 2 / _spatium);
}

int Rest::downLine() const
{
    qreal _spatium = spatium();
    return lrint((pos().y() + bbox().top() + _spatium) * 2 / _spatium);
}

LLVM/Clang

V524 It is odd that the body of '--' function is fully equivalent to the body of '++' function. ExecutorAddress.h 104


class ExecutorAddress {
  ....
  ExecutorAddress &operator++() {
    ++Addr;
    return *this;
  }
  ExecutorAddress &operator--() {
    --Addr;
    return *this;
  }
  ExecutorAddress operator++(int) { return ExecutorAddress(Addr++); }
  ExecutorAddress operator--(int) { return ExecutorAddress(Addr++); }  // <=

  ExecutorAddress &operator+=(const ExecutorAddrDiff Delta) {
    Addr += Delta.getValue();
    return *this;
  }

  ExecutorAddress &operator-=(const ExecutorAddrDiff Delta) {
    Addr -= Delta.getValue();
    return *this;
  }
  ....
private:
  uint64_t Addr = 0;
}

FaCT++

V524 It is odd that the body of 'p_begin' function is fully equivalent to the body of 's_end' function. TaxonomyCreator.h 82


ss_iterator s_begin ( void ) override { return beg; }
ss_iterator s_end ( void ) override { return end; }
ss_iterator p_begin ( void ) override { return end; }      // <=
ss_iterator p_end ( void ) override { return end; }

Blend2D

V524 It is odd that the body of 'end' function is fully equivalent to the body of 'begin' function. string.h 258


class BLString : public BLStringCore
{
public:
  // ....
  BL_NODISCARD
  BL_INLINE const char* begin() const noexcept
  {
    return impl->data + impl->size;
  }

  BL_NODISCARD
  BL_INLINE const char* end() const noexcept
  {
    return impl->data + impl->size;
  }
  // ....
}