Skip to content

Commit

Permalink
Fixed various issues found by PVS-Studio.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Aug 18, 2015
1 parent 625e7a1 commit 48ced3e
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 59 deletions.
2 changes: 1 addition & 1 deletion qtools/qcstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class QCString
/** creates a string with room for size characters
* @param[in] size the number of character to allocate (including the 0-terminator)
*/
QCString( int size ) : m_rep(size)
explicit QCString( int size ) : m_rep(size)
{
}

Expand Down
2 changes: 1 addition & 1 deletion qtools/qfile_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ bool QFile::open( int m )
} else {
length = (int)st.st_size;
ioIndex = (flags() & IO_Append) == 0 ? 0 : length;
if ( (flags() & !IO_Truncate) && length == 0 && isReadable() ) {
if ( !(flags()&IO_Truncate) && length == 0 && isReadable() ) {
// try if you can read from it (if you can, it's a sequential
// device; e.g. a file in the /proc filesystem)
int c = getch();
Expand Down
6 changes: 4 additions & 2 deletions qtools/qstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11957,7 +11957,8 @@ QString QString::visual(int index, int len)
QChar* QString::asciiToUnicode( const QByteArray& ba, uint* len )
{
if ( ba.isNull() ) {
*len = 0;
if ( len )
*len = 0;
return 0;
}
int l = 0;
Expand All @@ -11976,7 +11977,8 @@ QChar* QString::asciiToUnicode( const QByteArray& ba, uint* len )
static QChar* internalAsciiToUnicode( const QByteArray& ba, uint* len )
{
if ( ba.isNull() ) {
*len = 0;
if ( len )
*len = 0;
return 0;
}
int l = 0;
Expand Down
1 change: 0 additions & 1 deletion src/classdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,6 @@ void ClassDef::writeDocumentationContents(OutputList &ol,const QCString & /*page

QCString pageType = " ";
pageType += compoundTypeString();
toupper(pageType.at(1));

Doxygen::indexList->addIndexItem(this,0);

Expand Down
8 changes: 4 additions & 4 deletions src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
MemberList *ml = m_classDef->getMemberList(type);
if (ml)
{
list.reset(MemberListInfoContext::alloc(m_classDef,relPathAsString(),ml,title,detailed));
list.reset(MemberListInfoContext::alloc(m_classDef,relPathAsString(),ml,title,""));
}
}
if (list)
Expand Down Expand Up @@ -2312,7 +2312,7 @@ class NamespaceContext::Private : public DefinitionContext<NamespaceContext::Pri
MemberList *ml = m_namespaceDef->getMemberList(type);
if (ml)
{
list.reset(MemberListInfoContext::alloc(m_namespaceDef,relPathAsString(),ml,title,detailed));
list.reset(MemberListInfoContext::alloc(m_namespaceDef,relPathAsString(),ml,title,""));
}
}
if (list)
Expand Down Expand Up @@ -2672,7 +2672,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
MemberList *ml = m_fileDef->getMemberList(type);
if (ml)
{
list.reset(MemberListInfoContext::alloc(m_fileDef,relPathAsString(),ml,title,detailed));
list.reset(MemberListInfoContext::alloc(m_fileDef,relPathAsString(),ml,title,""));
}
}
if (list)
Expand Down Expand Up @@ -4453,7 +4453,7 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private>
MemberList *ml = m_groupDef->getMemberList(type);
if (ml)
{
list.reset(MemberListInfoContext::alloc(m_groupDef,relPathAsString(),ml,title,detailed));
list.reset(MemberListInfoContext::alloc(m_groupDef,relPathAsString(),ml,title,""));
}
}
if (list)
Expand Down
15 changes: 3 additions & 12 deletions src/docparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,18 +511,9 @@ static void checkUndocumentedParams()
errMsg+=" parameter '"+argName+"'";
}
}
if (g_memberDef->inheritsDocsFrom())
{
warn_doc_error(g_memberDef->getDefFileName(),
g_memberDef->getDefLine(),
substitute(errMsg,"%","%%"));
}
else
{
warn_doc_error(g_memberDef->getDefFileName(),
g_memberDef->getDefLine(),
substitute(errMsg,"%","%%"));
}
warn_doc_error(g_memberDef->getDefFileName(),
g_memberDef->getDefLine(),
substitute(errMsg,"%","%%"));
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/docsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,6 @@ void DocSets::addIndexItem(Definition *context,MemberDef *md,
if (ii)
{
decl=ii->includeName;
if (decl.isEmpty())
{
decl=ii->local;
}
}
}
else if (nd)
Expand Down
7 changes: 5 additions & 2 deletions src/doxygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,10 @@ static void findUsingDeclarations(EntryNav *rootNav)
else
{
Debug::print(Debug::Classes,0," Found used class %s in scope=%s\n",
qPrint(usingCd->name()),nd?qPrint(nd->name()):qPrint(fd->name()));
qPrint(usingCd->name()),
nd?qPrint(nd->name()):
fd?qPrint(fd->name()):
"<unknown>");
}

if (nd)
Expand Down Expand Up @@ -6120,7 +6123,7 @@ static void findMember(EntryNav *rootNav,
// stripTemplateSpecifiersFromScope(scopeName,FALSE).data());

ClassDef *tcd=findClassDefinition(fd,nd,scopeName);
if (tcd==0 && stripAnonymousNamespaceScope(cd->name())==scopeName)
if (tcd==0 && cd && stripAnonymousNamespaceScope(cd->name())==scopeName)
{
// don't be fooled by anonymous scopes
tcd=cd;
Expand Down
4 changes: 2 additions & 2 deletions src/htmldocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ void HtmlDocVisitor::visitPre(DocPara *p)
void HtmlDocVisitor::visitPost(DocPara *p)
{
bool needsTag = FALSE;
if (p && p->parent())
if (p->parent())
{
switch (p->parent()->kind())
{
Expand Down Expand Up @@ -1067,7 +1067,7 @@ void HtmlDocVisitor::visitPost(DocPara *p)
// the paragraph (<ul>,<dl>,<table>) then that will already have ended the
// paragraph and we don't need to do it here
int nodeIndex = p->children().count()-1;
if (p && nodeIndex>=0)
if (nodeIndex>=0)
{
while (nodeIndex>=0 && p->children().at(nodeIndex)->kind()==DocNode::Kind_WhiteSpace)
{
Expand Down
4 changes: 2 additions & 2 deletions src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3787,7 +3787,7 @@ static void writeIndex(OutputList &ol)
{
title = theTranslator->trMainPage();
}
else
else if (Doxygen::mainPage)
{
title = filterTitle(Doxygen::mainPage->title());
}
Expand Down Expand Up @@ -4086,7 +4086,7 @@ static void writeIndexHierarchyEntries(OutputList &ol,const QList<LayoutNavEntry
for (i=oldSize;i<newSize;i++) indexWritten.at(i)=FALSE;
}
//printf("starting %s kind=%d\n",lne->title().data(),lne->kind());
bool addToIndex=lne==0 || lne->visible();
bool addToIndex=lne->visible();
bool needsClosing=FALSE;
if (!indexWritten.at(index))
{
Expand Down
2 changes: 1 addition & 1 deletion src/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ class LayoutParser : public QXmlDefaultHandler
// no MainPage node... add one as the first item of the root node...
new LayoutNavEntry(m_rootNav,LayoutNavEntry::MainPage, TRUE,
/*Config_getBool("GENERATE_TREEVIEW") ? "main" :*/ "index",
theTranslator->trMainPage(),TRUE);
theTranslator->trMainPage(),"",TRUE);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/membergroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void MemberGroup::insertMember(MemberDef *md)
// md,md->name().data());

MemberDef *firstMd = memberList->getFirst();
if (inSameSection && memberList->count()>0 &&
if (inSameSection && firstMd &&
firstMd->getSectionList(m_parent)!=md->getSectionList(m_parent))
{
inSameSection=FALSE;
Expand Down
5 changes: 0 additions & 5 deletions src/outputgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ void OutputGenerator::startPlainFile(const char *name)
//printf("startPlainFile(%s)\n",name);
fileName=dir+"/"+name;
file = new QFile(fileName);
if (!file)
{
err("Could not create file object for %s\n",fileName.data());
exit(1);
}
if (!file->open(IO_WriteOnly))
{
err("Could not open file %s for writing\n",fileName.data());
Expand Down
15 changes: 6 additions & 9 deletions src/template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1978,16 +1978,13 @@ class ExpressionParser
TRACE(("{parseLiteral(%s)\n",m_curToken.id.data()));
ExprAst *expr = new ExprAstLiteral(m_curToken.id);
getNextToken();
if (expr)
while (m_curToken.type==ExprToken::Operator &&
m_curToken.op==Operator::Filter)
{
while (m_curToken.type==ExprToken::Operator &&
m_curToken.op==Operator::Filter)
{
getNextToken();
ExprAstFilter *filter = parseFilter();
if (!filter) break;
expr = new ExprAstFilterAppl(expr,filter);
}
getNextToken();
ExprAstFilter *filter = parseFilter();
if (!filter) break;
expr = new ExprAstFilterAppl(expr,filter);
}
TRACE(("}parseLiteral()\n"));
return expr;
Expand Down
13 changes: 6 additions & 7 deletions src/translator_tw.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,7 @@ class TranslatorChinesetraditional : public Translator
/*! This is put at the bottom of a class documentation page and is
* followed by a list of files that were used to generate the page.
*/
virtual QCString trGeneratedFromFiles(ClassDef::CompoundType compType,
bool single)
virtual QCString trGeneratedFromFiles(ClassDef::CompoundType compType,bool)
{ // here s is one of " Class", " Struct" or " Union"
// single is true implies a single file
QCString result=(QCString)"此";
Expand All @@ -766,7 +765,7 @@ class TranslatorChinesetraditional : public Translator
default: break;
}
result+=" 文件是由下列檔案中產生";
if (single) result+=":"; else result+=":";
result+=":";
return result;
}

Expand Down Expand Up @@ -1948,21 +1947,21 @@ class TranslatorChinesetraditional : public Translator
return result;
}
/** UNO IDL service page */
virtual QCString trServiceGeneratedFromFiles(bool single)
virtual QCString trServiceGeneratedFromFiles(bool)
{
// single is true implies a single file
QCString result=(QCString)"本服務的文件由以下的檔案"
"所產生";
if (single) result+=":"; else result+=":";
result+=":";
return result;
}
/** UNO IDL singleton page */
virtual QCString trSingletonGeneratedFromFiles(bool single)
virtual QCString trSingletonGeneratedFromFiles(bool)
{
// single is true implies a single file
QCString result=(QCString)"本singleton的文件由下面的檔案"
"所產生";
if (single) result+=":"; else result+=":";
result+=":";
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4291,7 +4291,7 @@ bool getDefs(const QCString &scName,
bool found=FALSE;
MemberListIterator mmli(*mn);
MemberDef *mmd;
for (mmli.toFirst();((mmd=mmli.current()) && !found);++mmli)
for (mmli.toFirst();(mmd=mmli.current());++mmli)
{
MemberDef *tmd = mmd->getEnumScope();
//printf("try member %s tmd=%s\n",mmd->name().data(),tmd?tmd->name().data():"<none>");
Expand Down Expand Up @@ -8353,7 +8353,7 @@ void convertProtectionLevel(
if (extractPrivate)
{
*outListType1=MemberListType_pubSlots;
*outListType1=MemberListType_proSlots;
*outListType2=MemberListType_proSlots;
}
else
{
Expand Down
2 changes: 0 additions & 2 deletions src/vhdldocgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,6 @@ QCString VhdlDocGen::getClassTitle(const ClassDef *cd)
{
QCString pageTitle;
if (cd==0) return "";
pageTitle+=cd->displayName();
pageTitle=VhdlDocGen::getClassName(cd);
int ii=cd->protection();
pageTitle+=" ";
Expand Down Expand Up @@ -2163,7 +2162,6 @@ void VhdlDocGen::writeVHDLDeclaration(MemberDef* mdef,OutputList &ol,
{
if (VhdlDocGen::isConfig(mdef) || VhdlDocGen::isCompInst(mdef))
{
nn=mdef->getOutputFileBase();
nn=ltype;
}
else
Expand Down
5 changes: 4 additions & 1 deletion src/vhdljjparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,10 @@ void VhdlParser::addCompInst(const char *n, const char* instName, const char* co
current->type=instName; // foo:instname e.g proto or work. proto(ttt)
current->exception=genLabels.lower(); // |arch|label1:label2...
current->name=n; // foo
current->args=lastCompound->name; // architecture name
if (lastCompound)
{
current->args=lastCompound->name; // architecture name
}
current->includeName=comp; // component/enity/configuration
int u=genLabels.find("|",1);
if (u>0)
Expand Down

0 comments on commit 48ced3e

Please sign in to comment.