[Bug 37118] New: PVS-Studio Error: Typos

wine-bugs at winehq.org wine-bugs at winehq.org
Sat Aug 16 13:04:27 CDT 2014


https://bugs.winehq.org/show_bug.cgi?id=37118

            Bug ID: 37118
           Summary: PVS-Studio Error: Typos
           Product: Wine
           Version: 1.7.22
          Hardware: x86
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: -unknown
          Assignee: wine-bugs at winehq.org
          Reporter: lukebenes at hotmail.com

V501 There are identical sub-expressions '!lpScaleWindowExtEx->xNum' to the
left and to the right of the '||' operator. enhmetafile.c 1418

...
if (!lpScaleWindowExtEx->xNum || !lpScaleWindowExtEx->xDenom ||
    !lpScaleWindowExtEx->xNum || !lpScaleWindowExtEx->yDenom)
  break;
...

The lpScaleWindowExtEx->xNum condition is checked twice. Instead of one of the
checks, the statement lpScaleWindowExtEx->yNum was most likely meant to be
used. The corresponding field is found in the structure declaration:

typedef struct {
    EMR  emr;
    LONG xNum;   //<==
    LONG xDenom;
    LONG yNum;   //<==
    LONG yDenom;
} EMRSCALEVIEWPORTEXTEX, *PEMRSCALEVIEWPORTEXTEX,
  EMRSCALEWINDOWEXTEX,   *PEMRSCALEWINDOWEXTEX;

V501 There are identical sub-expressions '!(types[i + 1] &
PathPointTypeBezier)' to the left and to the right of the '||' operator.
graphics.c 1751

...
for(i = 1; i < count; i++){
  ....
  if((i + 2 >= count) ||
    !(types[i + 1] & PathPointTypeBezier) ||
    !(types[i + 1] & PathPointTypeBezier)){
    ....
  }
  i += 2;
}

...

Another similar issue:

V501 There are identical sub-expressions to the left and to the right of the
'|' operator: VT_ARRAY | VT_ARRAY vartest.c 2161



details on the V501 error here:http://www.viva64.com/en/d/0090/


...

This fragment was discovered by the same diagnostic V501, but this time it
doesn't show the reason for identical conditions that clearly. Most likely, one
of them should contain types[i + 2] because the programmer has checked before
if the array item with the index larger than 'i' by 2 can be addressed.

V593 Consider reviewing the expression of the 'A = B != C' kind. The expression
is calculated as following: 'A = (B != C)'. request.c 3354

if ((hr = SafeArrayAccessData( sa, (void **)&ptr )) != S_OK)
  return hr;
if ((hr = SafeArrayGetUBound( sa, 1, &size ) != S_OK)) //<==
{
    SafeArrayUnaccessData( sa );
    return hr;
}

The precedence of the != operator is higher than that of the assignment
operator =. And you can see clearly well from the condition above that the
assignment should also be enclosed in another pair of parentheses as hr would
otherwise get value 0 or 1.


details on the V593 error here:http://www.viva64.com/en/d/0197/

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list