Proposed Fixes for Various GCC Warnings
#1
I've looked through all the warnings that GCC generates when compiling the current SVN for the linuxport with the -Wall flag set.

The following warnings can be fixed with very little effort:

Code:
GUIFont.cpp:51: warning: unused variable ‘nw’
GUIFont.cpp:51: warning: unused variable ‘nh’
GUIWindowVideoNav.cpp:1052: warning: unused variable ‘bDownload’
GUITextBox.cpp:483: warning: unused variable ‘size’
These variables look like they can be safely deleted.

Code:
FileCache.h:57:2: warning: no newline at end of file
Platinum/Source/Core/PltService.cpp:685:2: warning: no newline at end of file
Just add a newline at the end of the files.

Code:
VideoDatabase.cpp:3790: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long unsigned int’
VideoDatabase.cpp:3881: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long unsigned int’
These should be probably be "%lu" instead of "%d".

Code:
XBMChttp.cpp:2350: warning: control reaches end of non-void function
It doesn't really, maybe just return 0 or something to shut up gcc?

In UnrarXlib:
Code:
file.cpp: In member function ‘Int64 File::Tell()’:
file.cpp:501: warning: unused variable ‘HighDist’
file.cpp:503: warning: unused variable ‘pos’
Both HighDist and pos should be commented out as well.

Code:
file.cpp:8: warning: ‘CreatedFiles’ defined but not used
This is only referenced from commented out code, it should be commented out as well.

Code:
filefn.cpp:111: warning: unused variable ‘sm’
filefn.cpp:112: warning: unused variable ‘sc’
filefn.cpp:113: warning: unused variable ‘sa’
sm, sc, and sa should be inside the _WIN_32 ifdef since they're only referenced from there.

Code:
Thread.cpp:97: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘Uint32’
I think "%lu" should be "%d", but I'm not sure since it's a custom type.

Code:
pathfn.cpp:8: warning: unused variable ‘Found’
This should probably be commented out as well.

Code:
rar.cpp:349: warning: unused variable ‘TitleShown’
rar.cpp:346: warning: unused variable ‘TotalPackSize’
rar.cpp:346: warning: unused variable ‘TotalUnpSize’
rar.cpp:339: warning: unused variable ‘FileMatched’
rar.cpp:479: warning: unused variable ‘pPrev’
rar.cpp:480: warning: unused variable ‘TitleShown’
rar.cpp:473: warning: unused variable ‘FileMatched’
rar.cpp:475: warning: unused variable ‘TotalPackSize’
rar.cpp:475: warning: unused variable ‘TotalUnpSize’
None of these are ever used.

Code:
DVDOverlayRenderer.cpp:56: warning: unused variable ‘ey’
DVDOverlayRenderer.cpp:57: warning: unused variable ‘er’
Neither are mentioned again in the function.

Code:
winxml.cpp:157: warning: unused variable ‘bRefresh’
CDDARipper.cpp:204: warning: unused variable ‘iTrack’
Never used.

Code:
EncoderWav.cpp:75: warning: passing NULL to non-pointer argument 2 of ‘DWORD SetFilePointer(CXHandle*, LONG, LONG*, DWORD)’

SetFilePointer(m_hFile, NULL, NULL, FILE_BEGIN);
Should probably read:
Code:
SetFilePointer(m_hFile, 0, NULL, FILE_BEGIN);

These are all pretty trivial, so I doubt any developers will care that much about them. However, fixing/silencing these may make finding "real" warnings easier.
Reply
#2
please,

speak diff or somebody has to do all the work you just did all over again
Reply
#3
Yes. I'll generate some diffs and post them when I get a chance.
Reply
#4
Thumbs Up 
http://xboxmediacenter.com/wiki/HOW-TO_submit_a_patch
http://xboxmediacenter.com/wiki/Linux_port_project

Thanks
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#5
Thanks - just a note for whoever implements these: Most of them apply to trunk, so please apply them there first, or let me know when it's done and I'll merge them back.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#6
Here's part of the patch. However, I can't get linuxport head to compile. Some of the xrandr stuff seems to have broken compilation.

Code:
Index: xbmc/VideoDatabase.cpp
===================================================================
--- xbmc/VideoDatabase.cpp  (revision 11096)
+++ xbmc/VideoDatabase.cpp  (working copy)
@@ -3787,7 +3787,7 @@

     unsigned int time = timeGetTime();
     if (!m_pDS->query(strSQL.c_str())) return false;
-    CLog::Log(LOGDEBUG, "%s -  query took %d ms", __FUNCTION__, timeGetTime() - time); time = timeGetTime();
+    CLog::Log(LOGDEBUG, "%s -  query took %lu ms", __FUNCTION__, timeGetTime() - time); time = timeGetTime();
     int iRowsFound = m_pDS->num_rows();
     if (iRowsFound == 0)
     {
@@ -3878,7 +3878,7 @@
       }
       m_pDS->close();
     }
-    CLog::Log(LOGDEBUG, "%s item retrieval took %d ms", __FUNCTION__, timeGetTime() - time); time = timeGetTime();
+    CLog::Log(LOGDEBUG, "%s item retrieval took %lu ms", __FUNCTION__, timeGetTime() - time); time = timeGetTime();

//    CLog::Log(LOGDEBUG, "%s Time: %d ms", timeGetTime() - time);
     return true;
Index: xbmc/GUIWindowVideoNav.cpp
===================================================================
--- xbmc/GUIWindowVideoNav.cpp  (revision 11096)
+++ xbmc/GUIWindowVideoNav.cpp  (working copy)
@@ -1049,7 +1049,6 @@
         CDirectory::GetDirectory(tag.m_strPath,tbnItems,".tbn");^M
         CStdString strExpression;^M
         strExpression.Format("season[ ._-](0?%i)\\.tbn",m_vecItems[itemNumber]->GetVideoInfoTag()->m_iSeason);^M
-        bool bDownload=true;^M
         CRegExp reg;^M
         if (reg.RegComp(strExpression.c_str()))^M
         {^M

I'll upload the full patch to sourceforge once I can get svn to compile.
Reply
#7
Here's the compile-time error, that I got:

Code:
GraphicContext.cpp: In member function ‘void CGraphicContext::SetVideoResolution(RESOLUTION&, BOOL, bool)’:
GraphicContext.cpp:571: error: ‘g_xrandr’ was not declared in this scope
make[1]: *** [GraphicContext.o] Error 1
Reply
#8
It seems that when I install libxrandr-dev that the compilation error is fixed. Maybe these should be #ifdef'd out if not installed?
Reply
#9
Now I get this error:

Code:
In file included from FileFactory.cpp:34:
FileMMS.h:5:24: error: libmms/mms.h: No such file or directory
FileMMS.h:25: error: ISO C++ forbids declaration of ‘mms_t’ with no type
FileMMS.h:25: error: expected ‘;’ before ‘*’ token

Any ideas? Thanks.
Reply
#10
I'm sorry, I guess I should read the damn README file next time. Nevermind. I'm an idiot.
Reply
#11
Check the Readme.Linux file. Specifically the apt-get stuff you need. I believe libmms is now needed.

Edit: Disregard. Looks like we posted at the same time.
42.7% of all statistics are made up on the spot

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#12
SVN 11098+ will autodetect libmms, making it optional.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Please read and follow the forum rules.
For troubleshooting and bug reporting, please make sure you read this first.


Image
Reply
#13
Thanks.

I've uploaded my patch to sourceforge: https://sourceforge.net/tracker/index.php?func=detail&aid=1858654&group_id=87054&atid=581840
Reply
#14
I've uploaded a second patch that fixes some other GCC warnings. Compilations are now nearly warning-free!

https://sourceforge.net/tracker/index.ph...tid=581840
Reply
#15
Here's a large number of gcc warnings fixes when the linuxport source is compiled with the -Wextra and -pedantic flags.

The majority of these fixes involve removing extra commas and semicolons in .h files that are not ISO C++ compliant.

For example:
namespaces should not be followed by a ';'
the last element in an enumeration should not be followed by a ','

Additionally, there are a few (3-4) fixes for comparison between signed and unsigned variables. I tried to follow the intent of the original code when making changes. Nevertheless, these changes may need to be reviewed by an XBMC team member.

Finally, xbmc/linux/PlatformDefs.h contains a few anonymous structs. However, anonymous structs are NOT legal in ISO C++. I did not attempt to fix these because I fear that my changes may break something.

Overall, these changes should make it easier to compile the code under different compilers than gcc and MSVC.

https://sourceforge.net/tracker/index.ph...tid=581840
Reply

Logout Mark Read Team Forum Stats Members Help
Proposed Fixes for Various GCC Warnings0