Skip to content

Commit

Permalink
Fix Some Clang Static Analysis Warnings, #10612.
Browse files Browse the repository at this point in the history
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@35116 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information
monkeyman_67156 committed Nov 2, 2010
1 parent 19eed27 commit ce85f00
Show file tree
Hide file tree
Showing 20 changed files with 23 additions and 63 deletions.
10 changes: 0 additions & 10 deletions guilib/GUIButtonScroller.cpp
Expand Up @@ -719,14 +719,12 @@ void CGUIButtonScroller::RenderItem(float &posX, float &posY, int &iOffset, bool
color_t color = (m_label.focusedColor && iOffset == GetActiveButton()) ? m_label.focusedColor : m_label.textColor;
color_t blendedAlpha = (alpha * ((color & 0xff000000) >> 24)) / 255;
color_t blendedColor = (blendedAlpha << 24) | (color & 0xFFFFFF);
blendedAlpha = (alpha * ((m_label.shadowColor & 0xff000000) >> 24)) / 255;
color_t shadowColor = (alpha << 24) | (m_label.shadowColor & 0xFFFFFF);
CGUITextLayout::DrawText(m_label.font, fPosX, fPosY, blendedColor, shadowColor, label, m_label.align);
}
else
{
float fAlpha = 255.0f;
float fAlpha1 = 255.0f;
// check if we have a skinner-defined texture...
CGUITexture *pImage = m_vecButtons[iOffset]->imageNoFocus;
if (!pImage) pImage = &m_imgNoFocus;
Expand All @@ -737,35 +735,27 @@ void CGUIButtonScroller::RenderItem(float &posX, float &posY, int &iOffset, bool
if (posX < fStartAlpha)
{
fAlpha -= (fStartAlpha - posX) / (fStartAlpha - m_posX) * m_iAlpha * 2.55f;
fAlpha1 -= (fStartAlpha - (posX + m_imgFocus.GetWidth() + m_buttonGap)) / (fStartAlpha - m_posX) * m_iAlpha * 2.55f;
}
if (posX >= fEndAlpha)
{
fAlpha -= (posX - fEndAlpha) / (m_posX + m_width - fEndAlpha) * m_iAlpha * 2.55f;
fAlpha1 -= ((posX + m_imgFocus.GetWidth() + m_buttonGap) - fEndAlpha) / (m_posX + m_width - fEndAlpha) * m_iAlpha * 2.55f;
}
if (fAlpha < 0) fAlpha = 0;
if (fAlpha1 < 0) fAlpha1 = 0;
if (fAlpha > 255) fAlpha = 255.0f;
if (fAlpha1 > 255) fAlpha1 = 255.0f;
pImage->SetAlpha((unsigned char)(fAlpha + 0.5f));
}
else
{
if (posY < fStartAlpha)
{
fAlpha -= (fStartAlpha - posY) / (fStartAlpha - m_posY) * m_iAlpha * 2.55f;
fAlpha1 -= (fStartAlpha - (posY + m_imgFocus.GetHeight() + m_buttonGap)) / (fStartAlpha - m_posY) * m_iAlpha * 2.55f;
}
if (posY > fEndAlpha)
{
fAlpha -= (posY - fEndAlpha) / (m_posY + m_height - fEndAlpha) * m_iAlpha * 2.55f;
fAlpha1 -= ((posY + m_imgFocus.GetHeight() + m_buttonGap) - fEndAlpha) / (m_posY + m_height - fEndAlpha) * m_iAlpha * 2.55f;
}
if (fAlpha < 0) fAlpha = 0;
if (fAlpha1 < 0) fAlpha1 = 0;
if (fAlpha > 255) fAlpha = 255.0f;
if (fAlpha1 > 255) fAlpha1 = 255.0f;
pImage->SetAlpha((unsigned char)(fAlpha + 0.5f));
}
pImage->SetPosition(posX, posY);
Expand Down
2 changes: 1 addition & 1 deletion guilib/GUIFixedListContainer.cpp
Expand Up @@ -261,7 +261,7 @@ void CGUIFixedListContainer::SelectItem(int item)
int minCursor, maxCursor;
GetCursorRange(minCursor, maxCursor);

int cursor = m_cursor;
int cursor;
if ((int)m_items.size() - 1 - item <= maxCursor - m_fixedCursor)
cursor = std::max(m_fixedCursor, maxCursor + item - (int)m_items.size() + 1);
else if (item <= m_fixedCursor - minCursor)
Expand Down
3 changes: 0 additions & 3 deletions guilib/GUIProgressControl.cpp
Expand Up @@ -76,8 +76,6 @@ void CGUIProgressControl::Render()
fScaleY = m_guiBackground.GetTextureHeight() ? m_height / m_guiBackground.GetTextureHeight() : 1.0f;
fScaleX = m_guiBackground.GetTextureWidth() ? m_width / m_guiBackground.GetTextureWidth() : 1.0f;

float fWidth = m_fPercent;

float posX = m_guiBackground.GetXPosition();
float posY = m_guiBackground.GetYPosition();

Expand All @@ -104,7 +102,6 @@ void CGUIProgressControl::Render()
m_guiMid.SetWidth(width);
m_guiMid.Render();
}
posX += fWidth * fScaleX;
}
}
else
Expand Down
3 changes: 0 additions & 3 deletions guilib/Texture.cpp
Expand Up @@ -33,9 +33,6 @@
CBaseTexture::CBaseTexture(unsigned int width, unsigned int height, unsigned int format)
: m_hasAlpha( true )
{
#ifndef HAS_DX
m_texture = NULL;
#endif
m_pixels = NULL;
m_loadedToGPU = false;
Allocate(width, height, format);
Expand Down
3 changes: 1 addition & 2 deletions xbmc/FileSystem/FileShoutcast.cpp
Expand Up @@ -216,7 +216,6 @@ int64_t CFileShoutcast::GetLength()
bool CFileShoutcast::Open(const CURL& url)
{
m_lastTime = CTimeUtils::GetTimeMS();
int ret;

CGUIDialogProgress* dlgProgress = NULL;

Expand Down Expand Up @@ -260,7 +259,7 @@ bool CFileShoutcast::Open(const CURL& url)
dlgProgress->Progress();
}

if ((ret = rip_manager_start(rip_callback, &m_opt)) != SR_SUCCESS)
if (rip_manager_start(rip_callback, &m_opt) != SR_SUCCESS)
{
if (dlgProgress) dlgProgress->Close();
return false;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/FileSystem/RSSDirectory.cpp
Expand Up @@ -498,7 +498,7 @@ static void ParseItem(CFileItem* item, TiXmlElement* root, const CStdString& pat
{
if(best == resources.end())
best = it;
else if(it->width && it->height || best->width && best->height)
else if((it->width && it->height) || (best->width && best->height))
{
if(it->width*it->height > best->width*best->height)
best = it;
Expand Down
3 changes: 0 additions & 3 deletions xbmc/FileSystem/XBMSDirectory.cpp
Expand Up @@ -61,7 +61,6 @@ bool CXBMSDirectory::GetDirectory(const CStdString& strPathUtf8, CFileItemList &
{
unsigned long handle;
char *filename, *fileinfo;
bool rv = false;

CStdString strPath=strPathUtf8;
g_charsetConverter.utf8ToStringCharset(strPath);
Expand All @@ -87,7 +86,6 @@ bool CXBMSDirectory::GetDirectory(const CStdString& strPathUtf8, CFileItemList &
dc_context.username = ((strUserName.c_str() != NULL) && (strlen(strUserName.c_str()) > 0)) ? strUserName.c_str() : NULL;
dc_context.password = ((strPassword.c_str() != NULL) && (strlen(strPassword.c_str()) > 0)) ? strPassword.c_str() : NULL;
ccx_client_discover_servers(DiscoveryCallback, (void *)(&dc_context));
rv = S_OK;

return (items.Size()>iOldSize);
}
Expand Down Expand Up @@ -230,7 +228,6 @@ bool CXBMSDirectory::GetDirectory(const CStdString& strPathUtf8, CFileItemList &
free(fileinfo);
}
cc_xstream_client_close_all(conn);
rv = true;

if (conn != 0)
cc_xstream_client_disconnect(conn);
Expand Down
3 changes: 0 additions & 3 deletions xbmc/FileSystem/iso9660.cpp
Expand Up @@ -835,14 +835,11 @@ bool iso9660::ReadSectorFromCache(iso9660::isofile* pContext, DWORD sector, byte
if ( pContext->m_dwCircBuffBegin >= CIRC_BUFFER_SIZE )
pContext->m_dwCircBuffBegin -= CIRC_BUFFER_SIZE;
pContext->m_dwCircBuffSectorStart++;
SectorsInCircBuff--;
}
else
{
pContext->m_dwCircBuffBegin = pContext->m_dwCircBuffEnd = 0;
pContext->m_dwCircBuffSectorStart = 0;
SectorsInCircBuff = 0;
SectorIsAdjacentInBuffer = 0;
}
}
// Ok, we're ready to read the sector into the cache
Expand Down
4 changes: 2 additions & 2 deletions xbmc/WinSystem.cpp
Expand Up @@ -151,8 +151,8 @@ static void AddRefreshRate(vector<REFRESHRATE> &refreshrates, unsigned int addin

static bool rrSortPredicate (REFRESHRATE i, REFRESHRATE j)
{
return ( i.RefreshRate < j.RefreshRate
|| i.RefreshRate == j.RefreshRate && !i.Interlaced);
return ( (i.RefreshRate < j.RefreshRate)
|| (i.RefreshRate == j.RefreshRate && !i.Interlaced));
}

vector<REFRESHRATE> CWinSystemBase::RefreshRates(int screen, int width, int height)
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp
Expand Up @@ -254,9 +254,9 @@ DVDVideoPicture* CDVDCodecUtils::ConvertToYUV422PackedPicture(DVDVideoPicture *p
{
// Perform the scaling.
uint8_t* src[] = { pSrc->data[0], pSrc->data[1], pSrc->data[2], NULL };
int srcStride[] = { pSrc->iLineSize[0], pSrc->iLineSize[1], pSrc->iLineSize[2], NULL };
int srcStride[] = { pSrc->iLineSize[0], pSrc->iLineSize[1], pSrc->iLineSize[2], 0 };
uint8_t* dst[] = { pPicture->data[0], NULL, NULL, NULL };
int dstStride[] = { pPicture->iLineSize[0], NULL, NULL, NULL };
int dstStride[] = { pPicture->iLineSize[0], 0, 0, 0 };

int dstformat;
if (format == DVDVideoPicture::FMT_UYVY)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
Expand Up @@ -562,7 +562,7 @@ void CDVDPlayerAudio::Process()

// Zero out the frame data if we are supposed to silence the audio
if (m_silence)
memset(audioframe.data, NULL, audioframe.size);
memset(audioframe.data, 0, audioframe.size);

if( result & DECODE_FLAG_DROP )
{
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/paplayer/ADPCMCodec/ADPCMDll.cpp
Expand Up @@ -71,15 +71,15 @@ extern "C"
if (!info->f)
{
free(info);
return NULL;
return 0;
}

int iResult = getwavinfo(info);
if (iResult == -1)
{
fclose(info->f);
free(info);
return NULL;
return 0;
}

info->szBuf = (char*)malloc(XBOX_ADPCM_DSTSIZE*info->fmt.wChannels*4);
Expand Down
3 changes: 1 addition & 2 deletions xbmc/karaoke/karaokelyricstext.cpp
Expand Up @@ -375,7 +375,6 @@ void CKaraokeLyricsText::Render()
}

m_preambleLayout->Update( m_currentPreamble, maxWidth * 0.9f );
updatePreamble = false;
}

float x = maxWidth * 0.5f + g_settings.m_ResInfo[resolution].Overscan.left;
Expand Down Expand Up @@ -462,7 +461,7 @@ void CKaraokeLyricsText::rescanLyrics()
}

// Second, add spaces if less than 5%, and rescan to gather more data.
bool add_spaces = (spaces * 100 / syllables < 5) ? true : false;
bool add_spaces = (syllables && (spaces * 100 / syllables < 5)) ? true : false;
RESOLUTION res = g_graphicsContext.GetVideoResolution();
float maxWidth = (float) g_settings.m_ResInfo[res].Overscan.right - g_settings.m_ResInfo[res].Overscan.left;

Expand Down
2 changes: 1 addition & 1 deletion xbmc/linux/PlatformDefs.h
Expand Up @@ -184,7 +184,7 @@

typedef pthread_t ThreadIdentifier;

class CXHandle; // foward declaration
struct CXHandle; // forward declaration
typedef CXHandle* HANDLE;

typedef void* HINSTANCE;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/utils/ArabicShaping.cpp
Expand Up @@ -192,7 +192,7 @@ static fribidi_boolean IsTransparent(FriBidiChar c)

FriBidiChar* shape_arabic(FriBidiChar * str, int len)
{
CharRep crep;
CharRep crep = { 0 };
CombCharRep combcrep;
FriBidiChar * shaped =
(FriBidiChar *) malloc(sizeof(FriBidiChar) * (len + 1));
Expand Down
2 changes: 0 additions & 2 deletions xbmc/utils/LCD.cpp
Expand Up @@ -174,7 +174,6 @@ CStdString ILCD::GetProgressBar(double tCurrent, double tTotal)
if (m_iColumns > 0)
{
double dBlockSize = tTotal * 0.99 / m_iColumns / iBigBlock; // mult with 0.99 to show the last bar
double dBlockSizeRest = (tCurrent - ((int)(tCurrent / dBlockSize) * dBlockSize));

CStdString strProgressBar = "[";
for (int i = 1;i <= m_iColumns;i++)
Expand All @@ -191,7 +190,6 @@ CStdString ILCD::GetProgressBar(double tCurrent, double tTotal)
tmpTest = (tmpTest / dBlockSize);
if (tmpTest >= iBigBlock) tmpTest = iBigBlock - 1;
strProgressBar += char(cLCDsmallBlocks - (int)tmpTest);
dBlockSizeRest = 0;
}
//fill up the rest with blanks
else
Expand Down
4 changes: 1 addition & 3 deletions xbmc/utils/PerformanceSample.cpp
Expand Up @@ -62,11 +62,10 @@ void CPerformanceSample::Reset()

void CPerformanceSample::CheckPoint()
{
#ifdef HAS_PERFORMANCE_SAMPLE
int64_t tmNow;
tmNow = CurrentHostCounter();
#ifdef HAS_PERFORMANCE_SAMPLE
double elapsed = (double)(tmNow - m_tmStart) / (double)m_tmFreq.QuadPart;
#endif

double dUser=0.0, dSys=0.0;
#ifdef _LINUX
Expand All @@ -82,7 +81,6 @@ void CPerformanceSample::CheckPoint()
}
#endif

#ifdef HAS_PERFORMANCE_SAMPLE
g_application.GetPerformanceStats().AddSample(m_statName, PerformanceCounter(elapsed,dUser,dSys));
#endif

Expand Down
3 changes: 0 additions & 3 deletions xbmc/utils/RssReader.cpp
Expand Up @@ -254,8 +254,6 @@ void CRssReader::GetNewsItems(TiXmlElement* channelXmlNode, int iFeed)
typedef pair <CStdString, CStdStringW> StrPair;
list <CStdString>::iterator i;

bool bEmpty=true;

// Add the title tag in if we didn't pass any tags in at all
// Represents default behaviour before configurability

Expand All @@ -264,7 +262,6 @@ void CRssReader::GetNewsItems(TiXmlElement* channelXmlNode, int iFeed)

while (itemNode > 0)
{
bEmpty = false;
TiXmlNode* childNode = itemNode->FirstChild();
mTagElements.clear();
while (childNode > 0)
Expand Down
18 changes: 5 additions & 13 deletions xbmc/utils/Teletext.cpp
Expand Up @@ -647,7 +647,7 @@ bool CTeletextDecoder::InitDecoder()
m_TypeTTF.face_id = (FTC_FaceID) m_teletextFont.c_str();
m_TypeTTF.height = (FT_UShort) m_RenderInfo.FontHeight;
m_TypeTTF.flags = FT_LOAD_MONOCHROME;
if ((error = FTC_Manager_LookupFace(m_Manager, m_TypeTTF.face_id, &m_Face)))
if (FTC_Manager_LookupFace(m_Manager, m_TypeTTF.face_id, &m_Face))
{
m_TypeTTF.face_id = (FTC_FaceID) m_teletextFont.c_str();
if ((error = FTC_Manager_LookupFace(m_Manager, m_TypeTTF.face_id, &m_Face)))
Expand Down Expand Up @@ -733,7 +733,6 @@ void CTeletextDecoder::EndDecoder()

void CTeletextDecoder::PageInput(int Number)
{
int zoom = 0;
m_updateTexture = true;

/* clear m_TempPage */
Expand All @@ -759,9 +758,6 @@ void CTeletextDecoder::PageInput(int Number)
CopyBB2FB();
}

if (m_RenderInfo.ZoomMode == 1)
zoom = 1<<10;

m_RenderInfo.PosY = 0;

switch (m_RenderInfo.InputCounter)
Expand All @@ -785,7 +781,7 @@ void CTeletextDecoder::PageInput(int Number)
}

/* generate pagenumber */
m_TempPage |= Number << m_RenderInfo.InputCounter*4;
m_TempPage |= Number << (m_RenderInfo.InputCounter*4);

m_RenderInfo.InputCounter--;

Expand Down Expand Up @@ -2179,7 +2175,7 @@ void CTeletextDecoder::DrawShape(color_t *lfb, int xres, int x, int y, int shape
void CTeletextDecoder::RenderCharIntern(TextRenderInfo_t* RenderInfo, int Char, TextPageAttr_t *Attribute, int zoom, int yoffset)
{
int Row, Pitch;
int error, glyph;
int glyph;
color_t bgcolor, fgcolor;
int factor, xfactor;
unsigned char *sbitbuffer;
Expand Down Expand Up @@ -2227,7 +2223,7 @@ void CTeletextDecoder::RenderCharIntern(TextRenderInfo_t* RenderInfo, int Char,
return;
}

if ((error = FTC_SBitCache_Lookup(m_Cache, &m_TypeTTF, glyph, &m_sBit, NULL)) != 0)
if (FTC_SBitCache_Lookup(m_Cache, &m_TypeTTF, glyph, &m_sBit, NULL) != 0)
{
FillRect(m_TextureBuffer, m_RenderInfo.Width, m_RenderInfo.PosX, m_RenderInfo.PosY + yoffset, curfontwidth, m_RenderInfo.FontHeight, bgcolor);
m_RenderInfo.PosX += curfontwidth;
Expand All @@ -2254,7 +2250,7 @@ void CTeletextDecoder::RenderCharIntern(TextRenderInfo_t* RenderInfo, int Char,
Char = G2table[0][0x20+ Attribute->diacrit];
if ((glyph = FT_Get_Char_Index(m_Face, Char)))
{
if ((error = FTC_SBitCache_Lookup(m_Cache, &m_TypeTTF, glyph, &sbit_diacrit, NULL)) == 0)
if (FTC_SBitCache_Lookup(m_Cache, &m_TypeTTF, glyph, &sbit_diacrit, NULL) == 0)
{
sbitbuffer = localbuffer;
memcpy(sbitbuffer,m_sBit->buffer,m_sBit->pitch*m_sBit->height);
Expand Down Expand Up @@ -2798,7 +2794,6 @@ TextPageinfo_t* CTeletextDecoder::DecodePage(bool showl25, // 1=deco
PageAtrb[col] = atr;
for (col = 40; col < 24*40; col++)
PageChar[col] = number2char(PageChar[col]);
boxed = false;
return PageInfo; /* don't interpret irregular pages */
}
else if (PageInfo->function == FUNC_GPOP || PageInfo->function == FUNC_POP) /* object definitions */
Expand Down Expand Up @@ -2826,12 +2821,10 @@ TextPageinfo_t* CTeletextDecoder::DecodePage(bool showl25, // 1=deco
}
}
}
boxed = false;
return PageInfo; /* don't interpret irregular pages */
}
else if (PageInfo->function == FUNC_GDRCS || PageInfo->function == FUNC_DRCS) /* character definitions */
{
boxed = false;
return PageInfo; /* don't interpret irregular pages */
}
else
Expand Down Expand Up @@ -2865,7 +2858,6 @@ TextPageinfo_t* CTeletextDecoder::DecodePage(bool showl25, // 1=deco
}
if (parityerror)
{
boxed = false;
return PageInfo; /* don't interpret irregular pages */
}
}
Expand Down

0 comments on commit ce85f00

Please sign in to comment.