ref: dc27cf17aea942cf37cf6e94e3870af0bff3b9a0
parent: d9bbf207f64f81cdbe0dfbd20cea5961fb1210a6
author: Timothy B. Terriberry <tterribe@xiph.org>
date: Wed Aug 2 10:49:56 EDT 2017
Minor win32 warning fix. op_fopen() and op_freopen() declare these arguments as non-NULL, so when building with mingw, the compiler reasonably complains when we check to see if they're NULL. We could remove the OP_ARG_NONNULL tags, but the behavior of _wopen/_wfreopen appears to be to crash on NULL for either parameter. On Linux, the behavior appears to be to handle a NULL path (fopen returns NULL with errno set to EFAULT, and freopen returns the passed FILE * with errno set to EFAULT), but crash on a NULL mode. Keeping the OP_ARG_NONNULL tags promises that passing NULL results in undefined behavior, which is at least consistent with the behavior being different on different platforms. It's also consistent with the ABI promises of previous releases, which compilers linking against libopusfile might have taken advantage of.
--- a/src/stream.c
+++ b/src/stream.c
@@ -235,8 +235,7 @@
fp=fopen(_path,_mode);
#else
fp=NULL;
- if(_path==NULL||_mode==NULL)errno=EINVAL;
- else{
+ {
wchar_t *wpath;
wchar_t *wmode;
wpath=op_utf8_to_utf16(_path);
@@ -266,8 +265,7 @@
fp=freopen(_path,_mode,(FILE *)_stream);
#else
fp=NULL;
- if(_path==NULL||_mode==NULL)errno=EINVAL;
- else{
+ {
wchar_t *wpath;
wchar_t *wmode;
wpath=op_utf8_to_utf16(_path);