Fix various Clang static analyzer quibbles
This commit is contained in:
		
							parent
							
								
									86baf94ddf
								
							
						
					
					
						commit
						d6df22f9dc
					
				| 
						 | 
				
			
			@ -1323,7 +1323,9 @@ cWcharIs32BitUcs2Converterer::Convert(
 | 
			
		|||
        throw eConverterFatal( TSS_GetString( cCore, core::STR_ERR_ISNULL ) );
 | 
			
		||||
 | 
			
		||||
    // cast our dbchar_t to wchar_t's first
 | 
			
		||||
    ntwcs_t pwzBuffer = new wchar_t[ nCount + 1 ];
 | 
			
		||||
    std::vector<wchar_t> buf(nCount+1);
 | 
			
		||||
    wchar_t* pwzBuffer = &buf[0];
 | 
			
		||||
    
 | 
			
		||||
    for( size_t n = 0; n < nCount; n++ )
 | 
			
		||||
        pwzBuffer[n] = pwz[n];
 | 
			
		||||
    pwzBuffer[nCount] = 0x00; // null terminate
 | 
			
		||||
| 
						 | 
				
			
			@ -1358,7 +1360,8 @@ cWcharIs32BitUcs2Converterer::Convert(
 | 
			
		|||
        throw eConverterFatal( TSS_GetString( cCore, core::STR_ERR_ISNULL ) );
 | 
			
		||||
 | 
			
		||||
    // mb to wc to a buffer of wide chars then....
 | 
			
		||||
    wchar_t* pwzBuffer = new wchar_t[ nCount ];
 | 
			
		||||
    std::vector<wchar_t> buf(nCount);
 | 
			
		||||
    wchar_t* pwzBuffer = &buf[0];
 | 
			
		||||
 | 
			
		||||
    int nConv = tss_mbstowcs( pwzBuffer, pbz, nCount );
 | 
			
		||||
    if ( nConv == -1 )
 | 
			
		||||
| 
						 | 
				
			
			@ -1451,20 +1454,24 @@ cGoodEnoughConverterer::Convert(
 | 
			
		|||
        throw eConverterFatal( TSS_GetString( cCore, core::STR_ERR_ISNULL ) );
 | 
			
		||||
    
 | 
			
		||||
    char* at = pbz;
 | 
			
		||||
    const dbchar_t* dat = pwz;
 | 
			
		||||
    while ( *dat )
 | 
			
		||||
    {
 | 
			
		||||
        if( *dat > 0xFF )
 | 
			
		||||
        {
 | 
			
		||||
            *at = cConvertUtil::ConvertNonChar( *dat );
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            *at = (char)*dat;
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        at++;
 | 
			
		||||
        dat++;
 | 
			
		||||
    if (pwz)
 | 
			
		||||
    {
 | 
			
		||||
        const dbchar_t* dat = pwz;
 | 
			
		||||
        while ( *dat )
 | 
			
		||||
        {
 | 
			
		||||
            if( *dat > 0xFF )
 | 
			
		||||
            {
 | 
			
		||||
                *at = cConvertUtil::ConvertNonChar( *dat );
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                *at = (char)*dat;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            at++;
 | 
			
		||||
            dat++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    *at = 0x00;
 | 
			
		||||
| 
						 | 
				
			
			@ -1481,23 +1488,26 @@ cGoodEnoughConverterer::Convert(
 | 
			
		|||
    if ( pwz == 0 || ( pbz == 0 && nBytes ) )
 | 
			
		||||
        throw eConverterFatal( TSS_GetString( cCore, core::STR_ERR_ISNULL ) );
 | 
			
		||||
    
 | 
			
		||||
    const char* at = pbz;
 | 
			
		||||
    dbchar_t* dat = pwz;
 | 
			
		||||
    while ( *at )
 | 
			
		||||
    
 | 
			
		||||
    if (pbz)
 | 
			
		||||
    {
 | 
			
		||||
        if( (unsigned char)*at > (unsigned char)0x7Fu )
 | 
			
		||||
        const char* at = pbz;
 | 
			
		||||
        while ( *at )
 | 
			
		||||
        {
 | 
			
		||||
            *dat = cConvertUtil::ConvertNonChar( *at );
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            *dat = (uint16)(unsigned char)*at;
 | 
			
		||||
        }
 | 
			
		||||
            if( (unsigned char)*at > (unsigned char)0x7Fu )
 | 
			
		||||
            {
 | 
			
		||||
                *dat = cConvertUtil::ConvertNonChar( *at );
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                *dat = (uint16)(unsigned char)*at;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        dat++;
 | 
			
		||||
        at++;
 | 
			
		||||
            dat++;
 | 
			
		||||
            at++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    *dat = 0x0000;
 | 
			
		||||
 | 
			
		||||
    return( ( (size_t)dat - (size_t)pwz ) / sizeof( dbchar_t ) );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1105,8 +1105,8 @@ bool util_GetNextPathElement( const TSTRING& strPathC, TSTRING& strElem, int ind
 | 
			
		|||
    TSTRING strPath = strPathC; // writable local version
 | 
			
		||||
    
 | 
			
		||||
    bool fMoreSeps = true;
 | 
			
		||||
    TSTRING::size_type firstSep, nextSep, nextNonSep;
 | 
			
		||||
    firstSep = nextSep = nextNonSep = (TSTRING::size_type)-1;
 | 
			
		||||
    TSTRING::size_type nextSep, nextNonSep;
 | 
			
		||||
    nextSep = nextNonSep = (TSTRING::size_type)-1;
 | 
			
		||||
    for( int i = 0; i <= index && fMoreSeps; i++ )
 | 
			
		||||
    {        
 | 
			
		||||
        // go past leading separators
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -260,8 +260,12 @@ int cFCOPropVector::SetSize(int max)
 | 
			
		|||
    }
 | 
			
		||||
    else    //mpBuf!=NULL && max>msBitlength
 | 
			
		||||
    {
 | 
			
		||||
        (*mpBuf).resize (((max/msBitlength)+1), 0);
 | 
			
		||||
        return mSize = ((*mpBuf).capacity() * msBitlength);
 | 
			
		||||
        if (mpBuf)
 | 
			
		||||
        {
 | 
			
		||||
            (*mpBuf).resize (((max/msBitlength)+1), 0);
 | 
			
		||||
            mSize = ((*mpBuf).capacity() * msBitlength);
 | 
			
		||||
        }
 | 
			
		||||
        return mSize;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -353,12 +353,15 @@ void cIntegrityCheck::ProcessDir( cDbDataSourceIter dbIter, iFCODataSourceIter*
 | 
			
		|||
        if( dbIter.Done() )
 | 
			
		||||
        {
 | 
			
		||||
            ASSERT( pIter != 0);
 | 
			
		||||
            d.TraceDetail( "Examining <done> and %s\n", pIter->GetName().AsString().c_str() );
 | 
			
		||||
            //
 | 
			
		||||
            // these are all new entries, add them to the "Added" set...
 | 
			
		||||
            //
 | 
			
		||||
            ProcessAddedFCO( dbIter, pIter );
 | 
			
		||||
            pIter->Next();
 | 
			
		||||
            if (pIter)
 | 
			
		||||
            {
 | 
			
		||||
                d.TraceDetail( "Examining <done> and %s\n", pIter->GetName().AsString().c_str() );
 | 
			
		||||
                //
 | 
			
		||||
                // these are all new entries, add them to the "Added" set...
 | 
			
		||||
                //
 | 
			
		||||
                ProcessAddedFCO( dbIter, pIter );
 | 
			
		||||
                pIter->Next();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else if( ! pIter )
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -273,10 +273,6 @@ private:
 | 
			
		|||
    void        SendInit();// throw (eMailMessageError)
 | 
			
		||||
        // opens a pipe to sendmail and writes the header.
 | 
			
		||||
    
 | 
			
		||||
    FILE*       GetFilePointer() const;
 | 
			
		||||
        // returns a pointer to the current file pointer. Only valid between
 | 
			
		||||
        // SendInit() and SendFinit()
 | 
			
		||||
    
 | 
			
		||||
    void        SendFinit(); //throw (eMailMessageError)
 | 
			
		||||
        // closes the file descriptor, sending the rest of the message
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,8 +80,7 @@ bool cPipedMailMessage::Send()
 | 
			
		|||
 | 
			
		||||
    SendInit();
 | 
			
		||||
    
 | 
			
		||||
    FILE* sendPipe = GetFilePointer();
 | 
			
		||||
    ASSERT( sendPipe != 0 );
 | 
			
		||||
    ASSERT( mpFile != 0 );
 | 
			
		||||
   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
			
		||||
    // Get Body and Attachments
 | 
			
		||||
    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
			
		||||
| 
						 | 
				
			
			@ -213,8 +212,3 @@ void cPipedMailMessage::SendFinit() //throw ( eMailMessageError )
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FILE* cPipedMailMessage::GetFilePointer() const
 | 
			
		||||
{
 | 
			
		||||
    return mpFile;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -450,6 +450,7 @@ void cDbDebug::OutputResults( void )
 | 
			
		|||
// Begin code for manipulating Database -- This is just a straight port from the DbExplore code.  It's presence is
 | 
			
		||||
// purely for convenience, and for debugging this class.
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
/*
 | 
			
		||||
static inline bool IsSpace( TCHAR c )
 | 
			
		||||
{
 | 
			
		||||
    return ( (c == _T(' ')) || (c == _T('\t')) || (c == _T('\r')) || (c == _T('\n')) || (c == _T('\0')) );
 | 
			
		||||
| 
						 | 
				
			
			@ -460,7 +461,6 @@ static inline bool IsEnd( TCHAR c )
 | 
			
		|||
    return ( (c == _T('\0')) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// util_PrintFCO
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -514,13 +514,6 @@ cFCOReportChangeIter::cFCOReportChangeIter(const cFCOReportSpecIter& specIter)
 | 
			
		|||
    SetSpecIter(specIter);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cFCOReportChangeIter::cFCOReportChangeIter()
 | 
			
		||||
{
 | 
			
		||||
    mpData = new cFCOReportChangeIter_i;
 | 
			
		||||
    mpData->mpList  = 0;
 | 
			
		||||
    mpData->mIter   = mpData->mpList->begin();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cFCOReportChangeIter::cFCOReportChangeIter(const cFCOReportChangeIter& rhs)
 | 
			
		||||
{
 | 
			
		||||
    mpData = new cFCOReportChangeIter_i;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -227,7 +227,6 @@ class cFCOReportChangeIter
 | 
			
		|||
{
 | 
			
		||||
public:
 | 
			
		||||
    cFCOReportChangeIter(const cFCOReportSpecIter& specIter);
 | 
			
		||||
    cFCOReportChangeIter();
 | 
			
		||||
    cFCOReportChangeIter(const cFCOReportChangeIter& rhs);
 | 
			
		||||
    ~cFCOReportChangeIter();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -251,6 +250,8 @@ public:
 | 
			
		|||
    const cFCOPropVector&   GetChangeVector() const;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    cFCOReportChangeIter() {}
 | 
			
		||||
    
 | 
			
		||||
    cFCOReportChangeIter_i* mpData;
 | 
			
		||||
    // TODO -- if it turns out that we are creating a lot of these, we should consider
 | 
			
		||||
    // making a pool of them.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1519,6 +1519,9 @@ void cTextReportViewer::DisplayChangedProps( const iFCO* const pfcoOld, const iF
 | 
			
		|||
       
 | 
			
		||||
void cTextReportViewer::OutputAddedSummary( const cFCOReportSpecIter& ri, FCOList* pFCONameList )
 | 
			
		||||
{
 | 
			
		||||
    if (!pFCONameList)
 | 
			
		||||
        return;
 | 
			
		||||
    
 | 
			
		||||
    if( ! ri.GetAddedSet()->IsEmpty() )
 | 
			
		||||
    {
 | 
			
		||||
        (*mpOut) << TSS_GetString( cTW, tw::STR_ADDED ) << _T(":") << endl;
 | 
			
		||||
| 
						 | 
				
			
			@ -1539,6 +1542,9 @@ void cTextReportViewer::OutputAddedSummary( const cFCOReportSpecIter& ri, FCOLis
 | 
			
		|||
 | 
			
		||||
void cTextReportViewer::OutputRemovedSummary( const cFCOReportSpecIter& ri, FCOList* pFCONameList)
 | 
			
		||||
{
 | 
			
		||||
    if (!pFCONameList)
 | 
			
		||||
        return;
 | 
			
		||||
    
 | 
			
		||||
    if( ! ri.GetRemovedSet()->IsEmpty() )
 | 
			
		||||
    {
 | 
			
		||||
        (*mpOut) << TSS_GetString( cTW, tw::STR_REMOVED ) << _T(":") << endl;
 | 
			
		||||
| 
						 | 
				
			
			@ -1559,6 +1565,9 @@ void cTextReportViewer::OutputRemovedSummary( const cFCOReportSpecIter& ri, FCOL
 | 
			
		|||
 | 
			
		||||
void cTextReportViewer::OutputChangedSummary( const cFCOReportSpecIter& ri, FCOList* pFCONameList )
 | 
			
		||||
{
 | 
			
		||||
    if (!pFCONameList)
 | 
			
		||||
        return;
 | 
			
		||||
    
 | 
			
		||||
    if( ri.GetNumChanged() > 0 )
 | 
			
		||||
    {
 | 
			
		||||
        (*mpOut) << TSS_GetString( cTW, tw::STR_CHANGED ) << _T(":") << endl;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1557,15 +1557,11 @@ int cTWAModeExamine::Execute(cErrorQueue* pQueue)
 | 
			
		|||
                iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL, TSS_GetString(cTWAdmin, twadmin::STR_KEYS_DECRYPT ).c_str());
 | 
			
		||||
                iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL, TSS_GetString(cTW, tw::STR_NEWLINE ).c_str());
 | 
			
		||||
        
 | 
			
		||||
                bool siteDecrypts = false, localDecrypts = false;
 | 
			
		||||
        
 | 
			
		||||
                if (siteKey.KeysLoaded())
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    if (manip.TestDecryption(*siteKey.GetPublicKey(), false) != false)
 | 
			
		||||
                    {
 | 
			
		||||
                        siteDecrypts = true;
 | 
			
		||||
 | 
			
		||||
                        iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, TSS_GetString(cTWAdmin, twadmin::STR_SITEKEYFILE ).c_str());
 | 
			
		||||
 | 
			
		||||
                        iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, cDisplayEncoder::EncodeInline( mSiteKeyFile ).c_str());
 | 
			
		||||
| 
						 | 
				
			
			@ -1579,7 +1575,6 @@ int cTWAModeExamine::Execute(cErrorQueue* pQueue)
 | 
			
		|||
                {
 | 
			
		||||
                    if (manip.TestDecryption(*localKey.GetPublicKey(), false) != false)
 | 
			
		||||
                    {
 | 
			
		||||
                        localDecrypts = true;
 | 
			
		||||
                        iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, TSS_GetString(cTWAdmin, twadmin::STR_LOCALKEYFILE ).c_str());
 | 
			
		||||
 | 
			
		||||
                        iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, cDisplayEncoder::EncodeInline( mLocalKeyFile ).c_str());
 | 
			
		||||
| 
						 | 
				
			
			@ -1834,7 +1829,6 @@ int cTWAModeGenerateKeys::Execute(cErrorQueue* pQueue)
 | 
			
		|||
            //
 | 
			
		||||
            if(! bPrintedPassphraseHint)
 | 
			
		||||
            {
 | 
			
		||||
                bPrintedPassphraseHint = true;
 | 
			
		||||
                iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, TSS_GetString(cTWAdmin, twadmin::STR_PASSPHRASE_HINT).c_str() );
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
| 
						 | 
				
			
			@ -2162,7 +2156,6 @@ int cTWAModeChangePassphrases::Execute(cErrorQueue* pQueue)
 | 
			
		|||
            //
 | 
			
		||||
            if(! bPrintedPassphraseHint)
 | 
			
		||||
            {
 | 
			
		||||
                bPrintedPassphraseHint = true;
 | 
			
		||||
                iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, TSS_GetString(cTWAdmin, twadmin::STR_PASSPHRASE_HINT).c_str() );
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue