Skip to content

Commit

Permalink
Minor win32 warning fix.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Timothy B. Terriberry committed Aug 2, 2017
1 parent d9bbf20 commit dc27cf1
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ void *op_fopen(OpusFileCallbacks *_cb,const char *_path,const char *_mode){
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);
Expand Down Expand Up @@ -266,8 +265,7 @@ void *op_freopen(OpusFileCallbacks *_cb,const char *_path,const char *_mode,
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);
Expand Down

0 comments on commit dc27cf1

Please sign in to comment.