Permalink
Browse files

Fixed various issues found by PVS-Studio.

  • Loading branch information...
Dimitri van Heesch
Dimitri van Heesch committed Aug 18, 2015
1 parent 625e7a1 commit 48ced3ea8071b3141216482e2821e10250910947
@@ -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)
{
}
@@ -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();
@@ -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;
@@ -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;
@@ -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);
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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,"%","%%"));
}
}
}
@@ -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)
@@ -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)
@@ -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;
@@ -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())
{
@@ -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)
{
@@ -3787,7 +3787,7 @@ static void writeIndex(OutputList &ol)
{
title = theTranslator->trMainPage();
}
else
else if (Doxygen::mainPage)
{
title = filterTitle(Doxygen::mainPage->title());
}
@@ -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))
{
@@ -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);
}
}
@@ -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;
@@ -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());
@@ -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;
@@ -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)"此";
@@ -766,7 +765,7 @@ class TranslatorChinesetraditional : public Translator
default: break;
}
result+=" 文件是由下列檔案中產生";
if (single) result+=":"; else result+=":";
result+=":";
return result;
}
@@ -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;
}
@@ -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>");
@@ -8353,7 +8353,7 @@ void convertProtectionLevel(
if (extractPrivate)
{
*outListType1=MemberListType_pubSlots;
*outListType1=MemberListType_proSlots;
*outListType2=MemberListType_proSlots;
}
else
{
@@ -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+=" ";
@@ -2163,7 +2162,6 @@ void VhdlDocGen::writeVHDLDeclaration(MemberDef* mdef,OutputList &ol,
{
if (VhdlDocGen::isConfig(mdef) || VhdlDocGen::isCompInst(mdef))
{
nn=mdef->getOutputFileBase();
nn=ltype;
}
else
@@ -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)

0 comments on commit 48ced3e

Please sign in to comment.