Examples of errors detected by the V524 diagnostic.


V524. It is odd 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();


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));
}


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;