[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash-dev] [patch] Reduce compiler warnings in plugin test.cpp
From: |
strk |
Subject: |
Re: [Gnash-dev] [patch] Reduce compiler warnings in plugin test.cpp |
Date: |
Wed, 24 Nov 2010 16:17:07 +0100 |
Pushed 857a70
Note: I've applied this feeding your mail to ``git am -s''
wonderful :)
--strk;
On Wed, Nov 24, 2010 at 02:24:44PM +0100, Petter Reinholdtsen wrote:
>
> I had a look at the compiler warnings shown when doing make check,
> more specifically these warnings:
>
> test.cpp: In function 'int main(int, char**)':
> test.cpp:120: warning: unused variable 'obj'
> test.cpp: At global scope:
> test.cpp:41: warning: unused parameter 'argc'
> test.cpp:41: warning: unused parameter 'argv'
> test.cpp: In function 'void* NPN_GetStringIdentifier(const NPUTF8*)':
> test.cpp:308: warning: no return statement in function returning non-void
> test.cpp: At global scope:
> test.cpp:306: warning: unused parameter 'name'
> test.cpp: In function 'nsPluginInstanceBase*
> NS_NewPluginInstance(nsPluginCreateData*)':
> test.cpp:313: warning: no return statement in function returning non-void
> test.cpp: At global scope:
> test.cpp:311: warning: unused parameter 'aCreateDataStruct'
> test.cpp: In function 'NPError NS_PluginGetValue(NPPVariable, void*)':
> test.cpp:318: warning: no return statement in function returning non-void
> test.cpp: At global scope:
> test.cpp:316: warning: unused parameter 'aVariable'
> test.cpp:316: warning: unused parameter 'aValue'
> test.cpp: In function 'NPError NS_PluginInitialize()':
> test.cpp:323: warning: no return statement in function returning non-void
> test.cpp: At global scope:
> test.cpp:338: warning: unused parameter 'aPlugin'
> test.cpp: In function 'bool NPN_SetProperty(NPP_t*, NPObject*, void*, const
> NPVariant*)':
> test.cpp:348: warning: no return statement in function returning non-void
> test.cpp: At global scope:
> test.cpp:344: warning: unused parameter 'npp'
> test.cpp:344: warning: unused parameter 'obj'
> test.cpp:351: warning: unused parameter 'npp'
> test.cpp:351: warning: unused parameter 'obj'
> test.cpp:351: warning: unused parameter 'value'
> test.cpp:358: warning: unused parameter 'npp'
> test.cpp:358: warning: unused parameter 'obj'
> test.cpp:358: warning: unused parameter 'value'
> test.cpp: In function 'bool NPN_HasProperty(NPP_t*, NPObject*, void*, const
> NPVariant*)':
> test.cpp:366: warning: control reaches end of non-void function
>
> I left the unused variables alone, assume someone left them around for
> a purpose, and concentrated on the non-void functions lacking return
> values instead.
>
> This patch should get rid of them. The file have inconsistent
> indentation, so I went with the indentation used directly above the
> code I inserted. Allmost all the functions with missing return values
> are stubs, so I did not put much effort into generating a sensible
> return value.
>
> diff --git a/plugin/npapi/test.cpp b/plugin/npapi/test.cpp
> index 9a7b639..c2b5e29 100644
> --- a/plugin/npapi/test.cpp
> +++ b/plugin/npapi/test.cpp
> @@ -310,16 +310,19 @@ NPN_GetStringIdentifier(const NPUTF8 *name)
> nsPluginInstanceBase *
> NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct)
> {
> + return NULL;
> }
>
> NPError
> NS_PluginGetValue(NPPVariable aVariable, void *aValue)
> {
> + return NPERR_INVALID_INSTANCE_ERROR;
> }
>
> NPError
> NS_PluginInitialize()
> {
> + return NPERR_INVALID_INSTANCE_ERROR;
> }
>
> void
> @@ -345,6 +348,7 @@ NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier name,
> const NPVariant *value)
> {
> _properties[name] = const_cast<NPVariant *>(value);
> + return true;
> }
>
> bool
> @@ -363,6 +367,7 @@ NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier name,
> if (it != _properties.end()) {
> return true;
> }
> + return false;
> }
>
> void
>
> Does this patch make sense to you?
>
> After the change, the warning list look like this:
>
> test.cpp: In function 'int main(int, char**)':
> test.cpp:120: warning: unused variable 'obj'
> test.cpp: At global scope:
> test.cpp:41: warning: unused parameter 'argc'
> test.cpp:41: warning: unused parameter 'argv'
> test.cpp: In function 'void* NPN_GetStringIdentifier(const NPUTF8*)':
> test.cpp:308: warning: no return statement in function returning non-void
> test.cpp: At global scope:
> test.cpp:306: warning: unused parameter 'name'
> test.cpp:311: warning: unused parameter 'aCreateDataStruct'
> test.cpp:317: warning: unused parameter 'aVariable'
> test.cpp:317: warning: unused parameter 'aValue'
> test.cpp:341: warning: unused parameter 'aPlugin'
> test.cpp:347: warning: unused parameter 'npp'
> test.cpp:347: warning: unused parameter 'obj'
> test.cpp:355: warning: unused parameter 'npp'
> test.cpp:355: warning: unused parameter 'obj'
> test.cpp:355: warning: unused parameter 'value'
> test.cpp:362: warning: unused parameter 'npp'
> test.cpp:362: warning: unused parameter 'obj'
> test.cpp:362: warning: unused parameter 'value'
>
> I was unable to find a useful dummy value to return from
> NPN_GetStringIdentifier(), so that warning is left.
>
> Happy hacking,
> --
> Petter Reinholdtsen
>
> _______________________________________________
> Gnash-dev mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/gnash-dev
--
() Free GIS & Flash consultant/developer
/\ http://strk.keybit.net/services.html