zhanghui-new / npapi-sdk

Automatically exported from code.google.com/p/npapi-sdk
0 stars 0 forks source link

Const correctness of some functions' arguments #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. const char * mimeDescription = NP_GetMIMEDescription();
2. ...
3. NPP_New(mime, ...)

What is the expected output? What do you see instead?

I expect the code to compile. Instead, I see an error "cannot convert from 
'const char *' to 'char *'". Using non-const char* means that plugin can modify 
its mimetype at any time. I don't see this requirement anywhere. So I think 
plugin would only modify its local copy and shouldn't impact the browser.

What operating system are you compiling on?

Doesn't matter.

Please provide any additional information below.

This is actually a general issue with all readonly data passed as pointers. I 
think headers should clearly state which parameters are intended for output and 
which aren't.

actual: NPP_NewProcPtr (NPMIMEType pluginType, ...)
expected: NPP_NewProcPtr (const NPMIMEType pluginType, ...)

actual: NPP_NewStreamProcPtr(..., NPMIMEType type, ...)
expected: NPP_NewStreamProcPtr(..., const NPMIMEType type, ...)

actual: NPP_WriteProcPtr(..., void* buffer)
expected: NPP_WriteProcPtr(..., const void* buffer)

actual: NPP_SetValueProcPtr(..., void *value);
expected: NPP_SetValueProcPtr(..., const void *value);

Original issue reported on code.google.com by Van...@gmail.com on 23 Feb 2012 at 10:17

GoogleCodeExporter commented 8 years ago
oops... s/mime/mimeDescription/

Original comment by Van...@gmail.com on 23 Feb 2012 at 10:17

GoogleCodeExporter commented 8 years ago
const NPMIMEType should be replaced by const char *, i.e. pointer to const data

Original comment by Van...@gmail.com on 29 Feb 2012 at 3:52