gnash-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-dev] [patch] Reduce compiler warnings in plugin test.cpp


From: Petter Reinholdtsen
Subject: [Gnash-dev] [patch] Reduce compiler warnings in plugin test.cpp
Date: Wed, 24 Nov 2010 14:24:44 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]