Skip to content

Commit dc27cf1

Browse files
author
Timothy B. Terriberry
committed
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.
1 parent d9bbf20 commit dc27cf1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/stream.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ void *op_fopen(OpusFileCallbacks *_cb,const char *_path,const char *_mode){
235235
fp=fopen(_path,_mode);
236236
#else
237237
fp=NULL;
238-
if(_path==NULL||_mode==NULL)errno=EINVAL;
239-
else{
238+
{
240239
wchar_t *wpath;
241240
wchar_t *wmode;
242241
wpath=op_utf8_to_utf16(_path);
@@ -266,8 +265,7 @@ void *op_freopen(OpusFileCallbacks *_cb,const char *_path,const char *_mode,
266265
fp=freopen(_path,_mode,(FILE *)_stream);
267266
#else
268267
fp=NULL;
269-
if(_path==NULL||_mode==NULL)errno=EINVAL;
270-
else{
268+
{
271269
wchar_t *wpath;
272270
wchar_t *wmode;
273271
wpath=op_utf8_to_utf16(_path);

0 commit comments

Comments
 (0)