Вы находитесь на странице: 1из 8

. N2.

:
: 29.03.2011

, .
.
, .
, .

.
, . ,
, PVS-Studio
.
, . ,
"
".

1. '?:'
/++ '?:'. ,

, . :
int minValue = A < B ? A : B;
(. ).
- .

1 - /++,
, '?:' , , ,
. :
int Z = X + (A == B) ? 1 : 2;
, . , ,
X 1 2, (A == B).
"X + (A == B)". , :
int Z = (X + (A == B)) ? 1 : 2;
:

int Z = X + (A == B ? 1 : 2);
. ,
! ,
. .
.

V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a
lower priority than the '*' operator. physics dgminkowskiconv.cpp 1061
dgInt32 CalculateConvexShapeIntersection (...)
{
...
den = dgFloat32 (1.0e-24f) *
(den > dgFloat32 (0.0f)) ?
dgFloat32 (1.0f) : dgFloat32 (-1.0f);
...
}

V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a
lower priority than the '-' operator. views custom_frame_view.cc 400
static const int kClientEdgeThickness;
int height() const;
bool ShouldShowClientEdge() const;

void CustomFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {


...
int edge_height = titlebar_bottom->height() ShouldShowClientEdge() ? kClientEdgeThickness : 0;
...
}

V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a
lower priority than the '|' operator. vm vm_file_win.c 393
#define FILE_ATTRIBUTE_NORMAL

0x00000080

#define FILE_FLAG_NO_BUFFERING

0x20000000

vm_file* vm_file_fopen(...)
{
...
mds[3] = FILE_ATTRIBUTE_NORMAL |
(islog == 0) ? 0 : FILE_FLAG_NO_BUFFERING;
...
}
, .
. . ,
.
,
. , .
.
'?:'.
'?:'
if. , :
MyObject &ref = X ? A : B;

, , A B '?:'
:
MyObject *tmpPtr;
If (X)
tmpPtr = &A;
else
tmpPtr = &B;
MyObject &ref = *tmpPtr;
, '?:' . .
. '?:' -
. '?:'
. :
int Z = X + (A == B) ? 1 : 2;
:
int Z = X;
Z += A == B ? 1 : 2;
, IPP Samples, :
mds[3] = FILE_ATTRIBUTE_NORMAL;
mds[3] |= (islog == 0) ? 0 : FILE_FLAG_NO_BUFFERING;
. . , ,
.
'?:' .
. .

2.
- , /++
. , ,
.
.
, - , .
, ,
- .
, , . ,
, . , , ,
, .

,
.
, .
.
. .

V564 The '&' operator is applied to bool type value. You've probably forgotten to include parentheses or
intended to use the '&&' operator. game g_client.c 1534
#define SVF_CASTAI 0x00000010
char *ClientConnect(...) {
...
if ( !ent->r.svFlags & SVF_CASTAI ) {
...
}

V564 The '&' operator is applied to bool type value. You've probably forgotten to include parentheses or
intended to use the '&&' operator. dosbox sdlmain.cpp 519
static SDL_Surface * GFX_SetupSurfaceScaled(Bit32u sdl_flags,
Bit32u bpp) {
...
if (!sdl.blit.surface || (!sdl.blit.surface->flags&SDL_HWSURFACE)) {
...

Chromium:
V564 The '&' operator is applied to bool type value. You've probably forgotten to include parentheses or
intended to use the '&&' operator. base platform_file_win.cc 216
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo* info) {
...
info->is_directory =
file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0;
...
}
. . .
.
, . ,
. :
if (A == B && X != Y)
if (A - B < Foo() * 2)
(~, ^, &, |, <<, >>, ?:),
. . :
If ( ! (A & B))
x = A | B | (z < 1 ? 2 : 3);

"?:". "?:" - .
.

. ,
. .
. .
.
,
.

, ,
.

Вам также может понравиться