Examples of errors detected by the V590 diagnostic

V590. Consider inspecting this expression. The expression is excessive or contains a misprint.


Stickies

V590 Consider inspecting the '* pBuff == ' ' && * pBuff != '\0'' expression. The expression is excessive or contains a misprint. stickies stickygrep.cpp 875


void ExtractHexFromEdit (....)
{
  ...
  while (*pBuff == ' ' && *pBuff != '\0')
    pBuff++;
  ...
}

Although this is not an error, this operation is unnecessary.


FCEUX

V590 Consider inspecting the 'appliedSize == 'b' && appliedSize != 's'' expression. The expression is excessive or contains a misprint. fceux ram_search.cpp 877

V590 Consider inspecting the 'appliedSize == 'w' && appliedSize != 's'' expression. The expression is excessive or contains a misprint. fceux ram_search.cpp 879


bool Set_RS_Val()
{
  ...
  int appliedSize = rs_type_size;
  int appliedSign = rs_t;
  if(rs_c == 'n')
    appliedSize = 'w', appliedSign = 'u';
  if(rs_c == 'a')
    appliedSize = 'd', appliedSign = 'u';
  if((appliedSize == 'b' && appliedSize == 's' &&
     (rs_param < -128 || rs_param > 127)) ||
     (appliedSize == 'b' && appliedSize != 's' &&
     (rs_param < 0 || rs_param > 255)) ||
     (appliedSize == 'w' && appliedSize == 's' &&
     (rs_param < -32768 || rs_param > 32767)) ||
     (appliedSize == 'w' && appliedSize != 's' &&
     (rs_param < 0 || rs_param > 65535)))
       return false;
  ...
}

ReactOS

V590 Consider inspecting the '* token == ' ' && * token != '\0'' expression. The expression is excessive or contains a misprint. wininet http.c 800


static inline BOOL is_basic_auth_value( LPCWSTR pszAuthValue,
                                        LPWSTR *pszRealm )
{
  ...
  while (*token == ' ' && *token != '\0')
    token++;
  ...
}

//Enough:
while (*token == ' ')
  token++;

Identical errors can be found in some other places:

  • V590 Consider inspecting the '* realm == ' ' && * realm != '\0'' expression. The expression is excessive or contains a misprint. wininet http.c 794
  • V590 Consider inspecting the '* str == ' ' && * str != '\0'' expression. The expression is excessive or contains a misprint. wininet http.c 762

Notepad++

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. Notepad++ notepad_plus.cpp 853


int Notepad_plus::getHtmlXmlEncoding(....) const
{
  ...
  if (langT != L_XML && langT != L_HTML && langT == L_PHP)
    return -1;
  ...
}

Currently this code is equivalent to if (langT == L_PHP). The programmer probably wanted to write this code: if (langT != L_XML && langT != L_HTML && langT != L_PHP).


ICU

V590 Consider inspecting the 'secS == 0 && secS != 0x00010101' expression. The expression is excessive or contains a misprint. ucol.cpp 7893


#define UCOL_NO_MORE_CES 0x00010101

static UCollationResult
ucol_strcollRegular(....)
{
  ....
  uint32_t secS;
  ....
  while((secS == 0 && secS != UCOL_NO_MORE_CES) ||
        (isContinuation(secS) && !sInShifted)) {
  ....
}

Identical errors can be found in some other places:

  • V590 Consider inspecting the 'secT == 0 && secT != 0x00010101' expression. The expression is excessive or contains a misprint. ucol.cpp 7909

GNU C Library

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. dcigettext.c 582


char *DCIGETTEXT (....)
{
  ....
  /* Make CATEGORYVALUE point to the next element of the list. */
  while (categoryvalue[0] != '\0' && categoryvalue[0] == ':')
    ++categoryvalue;
  ....
}

Most likely this is what should be written here: while (categoryvalue[0] != '\0' && categoryvalue[0] != ':')


Tesseract

V590 Consider inspecting the 'wordstr[w] != '\0' && wordstr[w] == ' '' expression. The expression is excessive or contains a misprint. libtesseract303 baseapi.cpp 1742


bool TessBaseAPI::AdaptToWordStr(
  PageSegMode mode, const char* wordstr)
{
  ....
  while (wordstr[w] != '\0' && wordstr[w] == ' ')
    ++w;
  ....
}

Linux Kernel

V590 Consider inspecting the 'module_type == 0 || module_type != 68' expression. The expression is excessive or contains a misprint. dgap.c 6733


static int dgap_parsefile(char **in)
{
  ....
  int module_type = 0;
  ....
  module_type = dgap_gettok(in);
  if (module_type == 0 || module_type != PORTS ||
      module_type != MODEM) {
    pr_err("failed to set a type of module");
    return -1;
  }
  ....
}

Identical errors can be found in some other places:

  • V590 Consider inspecting the 'conc_type == 0 || conc_type != 65' expression. The expression is excessive or contains a misprint. dgap.c 6692

LibreOffice

V590 Consider inspecting the 'p[0] == 'C' || p[0] != 'c'' expression. The expression is excessive or contains a misprint. address.cxx 1593


sal_uInt16 ScRange::ParseCols( .... )
{
  ....
  const sal_Unicode* p = rStr.getStr();
  ....
  case formula::FormulaGrammar::CONV_XL_R1C1:
    if ((p[0] == 'C' || p[0] != 'c') &&
        NULL != (p = lcl_r1c1_get_col(
                          p, rDetails, &aStart, &ignored )))
    {
  ....
}

Identical errors can be found in some other places:

  • V590 Consider inspecting the 'p[0] == 'R' || p[0] != 'r'' expression. The expression is excessive or contains a misprint. address.cxx 1652

.NET CoreCLR

V590 Consider inspecting the 'wzPath[0] != L'\0' && wzPath[0] == L'\\'' expression. The expression is excessive or contains a misprint. cee_wks path.h 62


static inline bool
HasUncPrefix(LPCWSTR wzPath)
{
  _ASSERTE(!clr::str::IsNullOrEmpty(wzPath));
  return wzPath[0] != W('\0') && wzPath[0] == W('\\')
      && wzPath[1] != W('\0') && wzPath[1] == W('\\')
      && wzPath[2] != W('\0') && wzPath[2] != W('?');
}

Identical errors can be found in some other places:

  • V590 Consider inspecting this expression. The expression is excessive or contains a misprint. cee_wks path.h 72

Haiku Operation System

V590 Consider inspecting the 'path[i] == '/' && path[i] != '\0'' expression. The expression is excessive or contains a misprint. storage_support.cpp 309


status_t
parse_first_path_component(const char *path, int32& length,
               int32& nextComponent)
{
  ....
  for (; path[i] == '/' && path[i] != '\0'; i++);  // <=
  if (path[i] == '\0')  // this covers "" as well
    nextComponent = 0;
  else
    nextComponent = i;
  ....
}

Identical errors can be found in some other places:

  • V590 Consider inspecting this expression. The expression is excessive or contains a misprint. PoseView.cpp 5773
  • V590 Consider inspecting this expression. The expression is excessive or contains a misprint. Tracker.cpp 1728
  • V590 Consider inspecting the '* ptr == ';' && * ptr != '\0'' expression. The expression is excessive or contains a misprint. pc.c 316

Godot Engine

V590 Consider inspecting the 'arg[0] != 0 && arg[0] == ' '' expression. The expression is excessive or contains a misprint. godot_win.cpp 175


int WINAPI WinMain(....,LPSTR lpCmdLine, ....)
{
  ....
  char*  arg;
  arg  = lpCmdLine;
  ....
  while (arg[0] != 0 && arg[0] == ' ')
  {
    arg++;
  }
  ....
}

Unreal Engine 4

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. texturecompressormodule.cpp 1781


bool BuildTextureMips(
    const TArray<FImage>& InSourceMips,
    const FTextureBuildSettings& BuildSettings,
    TArray<FImage>& OutMipChain)
{
  ....
  if (BuildSettings.MipGenSettings != TMGS_LeaveExistingMips ||
      BuildSettings.MipGenSettings == TMGS_NoMipmaps ||
      bLongLatCubemap)
  {
    NumSourceMips = 1;
  }
  ....
}

FreeSWITCH

V590 Consider inspecting the '* data == ' ' && * data != '\0'' expression. The expression is excessive or contains a misprint. mod_curl.c 306


static char *print_json(switch_memory_pool_t *pool, ....)
{
  ....
  while (*data == ' ' && *data != '\0') {
    data++;
  }
  ....
}

Mozilla Thunderbird

V590 Consider inspecting the 'type != (1) && type == (2)' expression. The expression is excessive or contains a misprint. nswindowsregkey.cpp 313


#define REG_SZ        ( 1 )
#define REG_EXPAND_SZ ( 2 )
#define REG_MULTI_SZ  ( 7 )

NS_IMETHODIMP
nsWindowsRegKey::ReadStringValue(const nsAString& aName,
                                       nsAString& aResult)
{
  ....
  if (type != REG_SZ &&
      type == REG_EXPAND_SZ &&
      type == REG_MULTI_SZ)
  {
    return NS_ERROR_FAILURE;
  }
  ....
}

Wine Is Not an Emulator

V590 Consider inspecting the 'lret == 0 || lret != 234' expression. The expression is excessive or contains a misprint. winemenubuilder.c 3430


static void cleanup_menus(void)
{
  ...
  while (1)
  {
    ....
    lret = RegEnumValueW(....);
    if (lret == ERROR_SUCCESS || lret != ERROR_MORE_DATA)
      break;
  ....
}

Identical errors can be found in some other places:

  • V590 Consider inspecting the 'last_error == 183 || last_error != 3' expression. The expression is excessive or contains a misprint. schedsvc.c 90

ChakraCore

V590 Consider inspecting the 'sub[i] != '-' && sub[i] == '/'' expression. The expression is excessive or contains a misprint. rl.cpp 1388


const char *
stristr
(
  const char * str,
  const char * sub
)
{
  ....
  for (i = 0; i < len; i++)
  {
    if (tolower(str[i]) != tolower(sub[i]))
    {
      if ((str[i] != '/' && str[i] != '-') ||
            (sub[i] != '-' && sub[i] == '/')) {              / <=
           // if the mismatch is not between '/' and '-'
           break;
      }
    }
  }
  ....
}

FreeBSD Kernel

V590 Consider inspecting the 'error == 0 || error != - 1' expression. The expression is excessive or contains a misprint. nd6.c 2119


int
nd6_output_ifp(....)
{
  ....
  /* Use the SEND socket */
  error = send_sendso_input_hook(m, ifp, SND_OUT,
      ip6len);
  /* -1 == no app on SEND socket */
  if (error == 0 || error != -1)           // <=
      return (error);
  ....
}

Identical errors can be found in some other places:

  • V590 Consider inspecting the 'error == 0 || error != 35' expression. The expression is excessive or contains a misprint. if_ipw.c 1855
  • V590 Consider inspecting the 'error == 0 || error != 27' expression. The expression is excessive or contains a misprint. if_vmx.c 2747

FreeBSD Kernel

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. sig_verify.c 94


enum uni_ieact {
  UNI_IEACT_CLEAR = 0x00, /* clear call */
  ....
}

void
uni_mandate_epref(struct uni *uni, struct uni_ie_epref *epref)
{
  ....
  maxact = -1;
  FOREACH_ERR(e, uni) {
    if (e->ie == UNI_IE_EPREF)
      continue;
    if (e->act == UNI_IEACT_CLEAR)
      maxact = UNI_IEACT_CLEAR;
    else if (e->act == UNI_IEACT_MSG_REPORT) {
      if (maxact == -1 && maxact != UNI_IEACT_CLEAR)     // <=
        maxact = UNI_IEACT_MSG_REPORT;
    } else if (e->act == UNI_IEACT_MSG_IGNORE) {
      if (maxact == -1)
        maxact = UNI_IEACT_MSG_IGNORE;
    }
  }
  ....
}

Oracle VM Virtual Box

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. vboxdispcm.cpp 288


HRESULT vboxDispCmSessionCmdGet(....)
{
  ....
  Assert(hr == S_OK || hr == S_FALSE);
  if (hr == S_OK || hr != S_FALSE)     // <=
  {
      return hr;
  }
  ....
}

Identical errors can be found in some other places:

  • V590 Consider inspecting the 'err == 0L || err != 1237L' expression. The expression is excessive or contains a misprint. vboxdisplay.cpp 656
  • V590 Consider inspecting the 'rc == 3209 || rc != (- 3210)' expression. The expression is excessive or contains a misprint. vd.cpp 10876
  • V590 Consider inspecting the 'rc == 3209 || rc != (- 3210)' expression. The expression is excessive or contains a misprint. vd.cpp 10947
  • And 2 additional diagnostic messages.

The GTK+ Project

V590 Consider inspecting the 'str[0] == '\0' || str[0] != 'U'' expression. The expression is excessive or contains a misprint. gtkcomposetable.c 62


static gboolean
is_codepoint (const gchar *str)
{
  int i;

  /* 'U' is not code point but 'U00C0' is code point */
  if (str[0] == '\0' || str[0] != 'U' || str[1] == '\0')
    return FALSE;

  for (i = 1; str[i] != '\0'; i++)
    {
      if (!g_ascii_isxdigit (str[i]))
        return FALSE;
    }

  return TRUE;
}

OpenToonz

V590 Consider inspecting the 'state == (- 3) || state != 0' expression. The expression is excessive or contains a misprint. psdutils.cpp 174


int psdUnzipWithoutPrediction(....)
{
  ....
  do {
    state = inflate(&stream, Z_PARTIAL_FLUSH);
    if (state == Z_STREAM_END)
      break;
    if (state == Z_DATA_ERROR || state != Z_OK) // <=
      break;
  } while (stream.avail_out > 0);
  ....
}

ReactOS

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. generictable.c 278


PVOID NTAPI RtlLookupElementGenericTableFull(....)
{
  ....
  /* Check if we found anything */
  if ((*SearchResult == TableEmptyTree) ||
      (*SearchResult != TableFoundNode))
  {
    return NULL;
  }
  ....
}

PHP:Hypertext Preprocessor

V590 Consider inspecting the '* walk == 0 || * walk != '}'' expression. The expression is excessive or contains a misprint. php_pcre.c 1033


static int preg_get_backref(char **str, int *backref)
{
  ....
  register char *walk = *str;
  ....
  if (*walk == 0 || *walk != '}')
  ....
}

Wolfenstein 3D

V590 Consider inspecting the 'c >= 'A' && c <= 'A'' expression. The expression is excessive or contains a misprint. - ADDITIONAL IN CURRENT l_script.c 661


int PS_ReadNumber( script_t *script, token_t *token ) {
  ....
  while ( ( c >= '0' && c <= '9' ) ||
      ( c >= 'a' && c <= 'f' ) ||
      ( c >= 'A' && c <= 'A' ) )
  ....
}

MongoDB

V590 Consider inspecting the 'c >= '0' && c <= '0'' expression. The expression is excessive or contains a misprint. - ADDITIONAL IN CURRENT queryutil.cpp 104


string simpleRegex(....) {
  ....
  else if ((c >= 'A' && c <= 'Z') ||
          (c >= 'a' && c <= 'z') ||
          (c >= '0' && c <= '0') ||
          (c == '\0')) {
            // don't know what to do with these
            r = ss.str();
            break;
          }
  ....
}

Open X-Ray Engine

V590 Consider inspecting the '(0 != txt[1]) && ('#' == txt[1])' expression. The expression is excessive or contains a misprint. elog.cpp 29


void ELogCallback(void *context, LPCSTR txt)
{
  ....
  bool bDlg = ('#'==txt[0])||((0!=txt[1])&&('#'==txt[1]));
  if (bDlg){
    int mt = ('!'==txt[0])||((0!=txt[1])&&('!'==txt[1]))?1:0;
    ....
  }
}

Identical errors can be found in some other places:

  • V590 Consider inspecting the '(0 != txt[1]) && ('!' == txt[1])' expression. The expression is excessive or contains a misprint. elog.cpp 31

Nana

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. window_manager.cpp 467


void window_manager::destroy_handle(core_window_t* wd)
{
  ....
  if((wd->other.category == category::root_tag::value) ||
     (wd->other.category != category::frame_tag::value))  // <=
  {
   impl_->misc_register.erase(wd->root);
   impl_->wd_register.remove(wd);
  }
}

OpenSSL

V590 Consider inspecting the 'atype != - 1 && atype == 5' expression. The expression is excessive or contains a misprint. dh_ameth.c 670


static int dh_cms_set_peerkey(....)
{
  ....
  int atype;
  ....
  /* Only absent parameters allowed in RFC XXXX */
  if (atype != V_ASN1_UNDEF && atype == V_ASN1_NULL)
    goto err;
   ....
}

CryEngine V

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. goalop_crysis2.cpp 3779


void COPCrysis2FlightFireWeapons::ParseParam(....)
{
  ....
  else if (!paused &&
          (m_State == eFP_PAUSED) &&        // <=
          (m_State != eFP_PAUSED_OVERRIDE)) // <=
  ....
}

GCC

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. gensupport.c 1640


static const char *
alter_output_for_subst_insn (rtx insn, int alt)
{
  const char *insn_out, *sp ;
  char *old_out, *new_out, *cp;
  int i, j, new_len;

  insn_out = XTMPL (insn, 3);

  if (alt < 2 || *insn_out == '*' || *insn_out != '@')
    return insn_out;
  ....
}

GDB

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. macrocmd.c 214


static void
info_macro_command (char *args, int from_tty)
{
  ....
  char *arg_start = args;
  int processing_args = 1;

  while (processing_args
   && arg_start && *arg_start == '-' && *arg_start != '\0')
  ....
}

Chromium

V590 Consider inspecting the 'rv == OK || rv != ERR_ADDRESS_IN_USE' expression. The expression is excessive or contains a misprint. udp_socket_posix.cc 735


int UDPSocketPosix::RandomBind(const IPAddress& address)
{
  DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND
      && !rand_int_cb_.is_null());

  for (int i = 0; i < kBindRetries; ++i) {
    int rv = DoBind(IPEndPoint(address,
                               rand_int_cb_
                               .Run(kPortStart, kPortEnd)));
    if (rv == OK || rv != ERR_ADDRESS_IN_USE) // <=
      return rv;
  }
  return DoBind(IPEndPoint(address, 0));
}

Clang

V590 Consider inspecting this expression. The expression is excessive or contains a misprint. ARMISelDAGToDAG.cpp 1565


bool ARMDAGToDAGISel::tryT1IndexedLoad(SDNode *N) {
  LoadSDNode *LD = cast<LoadSDNode>(N);
  EVT LoadedVT = LD->getMemoryVT();
  ISD::MemIndexedMode AM = LD->getAddressingMode();
  if (AM == ISD::UNINDEXED ||                               // <=
      LD->getExtensionType() != ISD::NON_EXTLOAD ||
      AM != ISD::POST_INC ||                                // <=
      LoadedVT.getSimpleVT().SimpleTy != MVT::i32)
    return false;
  ....
}

The condition is long, so I'll highlight the most important part: AM == ISD::UNINDEXED || AM != ISD::POST_INC. This condition is redundant, and you can simplify it to: AM != ISD::POST_INC.

Identical errors can be found in some other places:

  • V590 Consider inspecting this expression. The expression is excessive or contains a misprint. ASTReader.cpp 4178
  • V590 Consider inspecting this expression. The expression is excessive or contains a misprint. BracesAroundStatementsCheck.cpp 46


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;