Hi,
We are using MQX 4.2.0 and I was quite surprised that _io_write is defined to take a non-const buffer for the data:
extern _mqx_int _io_write(MQX_FILE_PTR, void *, _mqx_int);
I would have expected the second parameter to be something like const void*, furthermore that it is used in the inline definition of fwrite:
#define fwrite(ptr,so,no,f) (_io_write(f,ptr,(so)*(no))/(so))
My question is: is it safe to assume that neither fwrite nor _io_write will modify the pointer that is given to them?
Can there be a problem to remove the const (using a cast) of an array we want to write using fwrite?
Thanks!
解決済! 解決策の投稿を見る。
Hi Ruby:
Thank you for your feedback. Yes, this is an issue. and it is fixed in MQX v5.
Your can fixed it by yourself.
For MQX v5 we did a full clean up of the code and we made things more consitent and up to date.
Regards
Daniel
Hi Ruby:
Thank you for your feedback. Yes, this is an issue. and it is fixed in MQX v5.
Your can fixed it by yourself.
For MQX v5 we did a full clean up of the code and we made things more consitent and up to date.
Regards
Daniel
Hi Daniel,
Thank you for your answer.
Just to be clear, the issue here is only that the parameter is not declared as const?
I mean, it is used as const (i.e. not modified) by the _io_write implementation right?
If so, I guess that _strnlen is the same (i.e. the first parameter is not modified and can be considered as const char*). I stumbled upon it yesterday after my question.
Thanks!
Yes, you are right.
Regards
Daniel