Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const correctness of some functions' arguments #16

Open
GoogleCodeExporter opened this issue Sep 1, 2015 · 2 comments
Open

Const correctness of some functions' arguments #16

GoogleCodeExporter opened this issue Sep 1, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

oops... s/mime/mimeDescription/

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

@GoogleCodeExporter
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant