Examples of errors detected by the V649 diagnostic.


V649. There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless.


RunAsAdmin Explorer Shim

V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 67, 70. cannonical_xml.h 70


class xmlInputCharData {
public:
  static bool isBaseChar(wchar_t l) {
    ....
    if (l >= 0x06BA && l <= 0x06BE) return true;
    if (l >= 0x06C0 && l <= 0x06CE) return true;
    if (l >= 0x06D0 && l <= 0x06D3) return true;
    if (l == 0x06D5) return true;                  // <=
    if (l >= 0x06E5 && l <= 0x06E6) return true;
    if (l >= 0x0905 && l <= 0x0939) return true;
    if (l == 0x06D5) return true;                  // <=
    if (l >= 0x0958 && l <= 0x0961) return true;
    if (l >= 0x0985 && l <= 0x098C) return true;
    if (l >= 0x098F && l <= 0x0990) return true;
    ....
  }

Miranda IM

V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 693, 696. cluiframes.c 696


int CLUIFramesGetalClientFrame(void)
{
  int i;

  if(alclientFrame!=-1)
    return alclientFrame;

  if(alclientFrame!=-1)
  {
    /* this value could become invalid if RemoveItemFromList
     * was called, so we double-check */
    ....
  }
}

Similar errors can be found in some other places:

  • V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 147, 148. init.c 148
  • V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 909, 915. icq_direct.cpp 915
  • V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 343, 347. jabber_rc.cpp 347

Wolfenstein 3D

V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 243, 262. tr_animation.c 262


#define REFLAG_FULL_LOD     8   // force a FULL lod
#define REFLAG_FORCE_LOD    8   // force a low lod

float R_CalcMDSLod(....)
{
  .....
  if ( refent->reFlags & REFLAG_FULL_LOD )
  {
    return 1.0f;
  }
  ....
  if ( refent->reFlags & REFLAG_FORCE_LOD )
  {
    flod *= 0.5;
  }
  ....
}

Coin3D

V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 1205, 1206. sbprofilingdata.cpp 1206


int
SbProfilingData::operator == (const SbProfilingData & rhs) const
{
  if (this->actionType != rhs.actionType) return FALSE;
  if (this->actionStartTime != rhs.actionStopTime) return FALSE;
  if (this->actionStartTime != rhs.actionStopTime) return FALSE;
  ....
}

Micro-Manager

V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 2918, 2922. LeicaDMI.cpp 2922


int AFC::Initialize()
{
  int ret = DEVICE_OK;
  ....
  if (ret != DEVICE_OK)
    return ret;
  AddAllowedValue("DichroicMirrorIn", "0", 0);
  AddAllowedValue("DichroicMirrorIn", "1", 1);
  if (ret != DEVICE_OK)
    return ret;
  ....
}

Not terrible, but second if() does not make sense.

Similar errors can be found in some other places:

  • V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 192, 198. AAAOTF.cpp 198
  • V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 507, 513. AAAOTF.cpp 513
  • V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 1060, 1073. LeicaDMI.cpp 1073
  • And 12 additional diagnostic messages.

Blender

V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 1672, 1675. writeffmpeg.c 1675


bool BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd)
{
    int codec = rd->ffcodecdata.codec;
    if (codec == AV_CODEC_ID_QTRLE)
        return true;
    if (codec == AV_CODEC_ID_PNG)
        return true;
    if (codec == AV_CODEC_ID_PNG)
        return true;
    ....
}

Blender

V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 331, 332. writefile.c 332


static void writedata_do_write(....)
{
  if ((wd == NULL) || wd->error ||
      (mem == NULL) || memlen < 1) return;
  if (wd->error) return;
  ....
}

Clang

V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 4410, 4413. MachODump.cpp 4413


static bool print_class_ro64_t(....) {
  ....
  const char *r;
  uint32_t offset, xoffset, left;
  ....
  r = get_pointer_64(p, offset, left, S, info);
  if (r == nullptr || left < sizeof(struct class_ro64_t))   // <=
    return false;                                           // <=
  memset(&cro, '\0', sizeof(struct class_ro64_t));
  if (left < sizeof(struct class_ro64_t)) {                 // <=
    memcpy(&cro, r, left);
    outs() << "   (class_ro_t entends past the .......)\n";
  } else
    memcpy(&cro, r, sizeof(struct class_ro64_t));
  ....
}

EFL Core Libraries

V649 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains function return. This means that the second 'if' statement is senseless. Check lines: 2282, 2285. ecore_con.c 2285


static Eina_Bool
_ecore_con_cl_handler(void *data,
                      Ecore_Fd_Handler *fd_handler)
{
   Ecore_Con_Server *obj = data;
   Eina_Bool want_read, want_write;
   Ecore_Con_Server_Data *svr =
     eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS);

   if (svr->delete_me)
     return ECORE_CALLBACK_RENEW;

   if (svr->delete_me)
     return ECORE_CALLBACK_RENEW;
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;