Vous êtes sur la page 1sur 10

PVS-Studio vs Chromium -

:
: 13.10.2011
Chromium .
, PVS-Studio , Chromium
. ,
Chromium, . ,
, , Chromium - ,
. .
, , . ,
, .
Chromium
PVS-Studio. , , ,
PVS-Studio:
http://www.viva64.com/ru/b/0092/

N1
std::string TestFileIO::TestParallelReads() {
...
const char* expected_result_1 =
"__border__abc__border__";
const char* expected_result_2 =
"__border__defghijkl__border__";
if (strncmp(extended_buf_1, expected_result_1,
sizeof(expected_result_1)) != 0 ||
strncmp(extended_buf_2, expected_result_2,
sizeof(expected_result_2)) != 0) {
...
}
PVS-Studio:
V579 The strncmp function receives the pointer and its size as arguments. It is possibly a mistake.
Inspect the third argument. ppapi_tests test_file_io.cc 759

V579 The strncmp function receives the pointer and its size as arguments. It is possibly a mistake.
Inspect the third argument. ppapi_tests test_file_io.cc 761
strncmp() ,
.
sizeof(). sizeof() ,
.

N2
int

AffixMgr::parse_convtable(..., const char * keyword)

{
...
if (strncmp(piece, keyword, sizeof(keyword)) != 0) {
...
}
PVS-Studio:
V579 The strncmp function receives the pointer and its size as arguments. It is possibly a mistake.
Inspect the third argument. hunspell affixmgr.cxx 3545
, 4 8 ,
.

N3
#define SEC_ASN1_CHOICE

0x100000

typedef struct sec_ASN1Template_struct {


unsigned long kind;
...
} SEC_ASN1Template;

PRBool SEC_ASN1IsTemplateSimple(
const SEC_ASN1Template *theTemplate)
{
...

if (!theTemplate->kind & SEC_ASN1_CHOICE) {


...
}
PVS-Studio:
V564 The '&' operator is applied to bool type value. You've probably forgotten to include parentheses or
intended to use the '&&' operator. nss secasn1u.c 121
. :
if (!(theTemplate->kind & SEC_ASN1_CHOICE)) {

N4
bool GetPlatformFileInfo(...) {
...
info->is_directory =
file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0;
...
}
PVS-Studio:
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 219
. :
info->is_directory =
(file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;

N5
WebRtc_Word32
interpolator::SupportedVideoType(VideoType srcVideoType,
VideoType dstVideoType)
{
...
if ((srcVideoType != kI420) ||

(srcVideoType != kIYUV) ||
(srcVideoType != kYV12))
{
return -1;
}
...
}
PVS-Studio:
V547 Expression is always true. Probably the '&&' operator should be used here. webrtc_vplib
interpolator.cc 119
(A != 123 || A!= 321) . , ,
-.

N6
static GLenum
get_temp_image_type(GLcontext *ctx, GLenum baseFormat)
{
...
if (ctx->DrawBuffer->Visual.redBits <= 8)
return GL_UNSIGNED_BYTE;
else if (ctx->DrawBuffer->Visual.redBits <= 8)
return GL_UNSIGNED_SHORT;
else
return GL_FLOAT;
...
}
PVS-Studio:
V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error
presence. Check lines: 2520, 2522. osmesa meta.c 2520
. , :
if (ctx->DrawBuffer->Visual.redBits <= 8)

return GL_UNSIGNED_BYTE;
else if (ctx->DrawBuffer->Visual.redBits <= 16)
return GL_UNSIGNED_SHORT;

N7
WebRtc_Word32 ModuleFileUtility::UpdateWavHeader(OutStream& wav)
{
...
if(STR_CASE_CMP(codec_info_.plname, "L16") == 0)
{
res = WriteWavHeader(wav, codec_info_.plfreq, 2,
channels, kWaveFormatPcm, _bytesWritten);
} else if(STR_CASE_CMP(codec_info_.plname, "PCMU") == 0) {
res = WriteWavHeader(wav, 8000, 1, channels,
kWaveFormatMuLaw, _bytesWritten);
} else if(STR_CASE_CMP(codec_info_.plname, "PCMU") == 0) {
res = WriteWavHeader(wav, 8000, 1, channels,
kWaveFormatALaw, _bytesWritten);
} else {
...
}

PVS-Studio:
V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error
presence. Check lines: 1324, 1327. media_file media_file_utility.cc 1324
'plname' "PCMU". ,
.

N8
enum ContentSettingsType;
struct EntryMapKey {

ContentSettingsType content_type;
...
};

bool OriginIdentifierValueMap::EntryMapKey::operator<(
const OriginIdentifierValueMap::EntryMapKey& other) const {
if (content_type < other.content_type)
return true;
else if (other.content_type > content_type)
return false;
return (resource_identifier < other.resource_identifier);
}
PVS-Studio:
V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error
presence. Check lines: 61, 63. browser content_settings_origin_identifier_value_map.cc 61
: "A < B". : "B > A". ,
. , .

N9
WebRtc_Word32
RTPReceiverVideo::ReceiveH263Codec(...)
{
...
if (IP_PACKET_SIZE < parsedPacket.info.H263.dataLength +
parsedPacket.info.H263.insert2byteStartCode? 2:0)
...
}
PVS-Studio:
V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a
lower priority than the '+' operator. rtp_rtcp rtp_receiver_video.cc 480

'?:' , '+'.
, . :
if (IP_PACKET_SIZE < parsedPacket.info.H263.dataLength +
(parsedPacket.info.H263.insert2byteStartCode ? 2:0))

:
V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a
lower priority than the '+' operator. rtp_rtcp rtp_receiver_video.cc 504

N10
static int
xmlXPathCompOpEvalFirst(...)
{
...
total += xmlXPathCompOpEvalFirst(...);
...
total =+ xmlXPathCompOpEvalFilterFirst(ctxt, op, first);
...
}
PVS-Studio:
V588 The expression of the 'A =+ B' kind is utilized. Consider reviewing it, as it is possible that 'A += B'
was meant. libxml xpath.c 12676
, total . ,
"+=", "=+".

N11
static VisiblePosition updateAXLineStartForVisiblePosition(...)
{
...
tempPosition = startPosition.previous();
if (tempPosition.isNull() || tempPosition.isNull())

break;
...
}
PVS-Studio:
V501 There are identical sub-expressions 'tempPosition.isNull ()' to the left and to the right of the '||'
operator. webcore_remaining accessibilityobject.cpp 489
.

N12
TEST(SharedMemoryTest, MultipleThreads) {
...
int threadcounts[] = { 1, kNumThreads };
for (size_t i = 0;
i < sizeof(threadcounts) / sizeof(threadcounts); i++) {
...
}
PVS-Studio:
V501 There are identical sub-expressions 'sizeof (threadcounts)' to the left and to the right of the '/'
operator. base_unittests shared_memory_unittest.cc 231
- , - . :
for (size_t i = 0;
i < sizeof(threadcounts) / sizeof(*threadcounts); i++) {

N13
bool
ir_algebraic_visitor::reassociate_constant(...)
{
if (ir1->operands[0]->type->is_matrix() ||
ir1->operands[0]->type->is_matrix() ||
ir2->operands[1]->type->is_matrix() ||

ir2->operands[1]->type->is_matrix())
return false;
}
PVS-Studio:
V501 There are identical sub-expressions 'ir1->operands [0]->type->is_matrix ()' to the left and to the
right of the '||' operator. mesa ir_algebraic.cpp 189
Copy-Paste, .
:
if (ir1->operands[0]->type->is_matrix() ||
ir1->operands[1]->type->is_matrix() ||
ir2->operands[0]->type->is_matrix() ||
ir2->operands[1]->type->is_matrix())

N15
#define FRAMESAMPLES_HALF

240

#define FRAMESAMPLES

480

typedef struct {
...
WebRtc_Word16 realFFT[FRAMESAMPLES_HALF];
WebRtc_Word16 imagFFT[FRAMESAMPLES_HALF];
} ISACUBSaveEncDataStruct;

int WebRtcIsac_EncodeStoredDataUb12(...)
{
...
for(n = 0; n < FRAMESAMPLES; n++)
{
realFFT[n] = (WebRtc_Word16)
(scale * (float)ISACSavedEnc_obj->realFFT[n] + 0.5f);

imagFFT[n] = (WebRtc_Word16)
(scale * (float)ISACSavedEnc_obj->imagFFT[n] + 0.5f);
}
...
}
PVS-Studio:
V557 Array overrun is possible. The value of 'n' index could reach 479. iSAC encode.c 1307
V557 Array overrun is possible. The value of 'n' index could reach 479. iSAC encode.c 1308
.
FRAMESAMPLES_HALF .

N16
static int
coff_helper_gasflags(...)
{
...
case 'd':
datasect = 1;
load = 1;
readonly = 0;
case 'x':
code = 1;
load = 1;
break;
...
}
PVS-Studio:
V519 The 'load' variable is assigned values twice successively. Perhaps this is a mistake. Check lines:
1346, 1350. yasm coff-objfmt.c 1350
, 'break;'.