Skip to content

Commit

Permalink
rtlib: FileFlush device driver calls
Browse files Browse the repository at this point in the history
- no need to check for FB_FILE_TYPE_NORMAL, if device has pfnFlush function ptr set, then it's OK to call
- besides, OPEN "CON" is FB_FILE_TYPE_CONSOLE, and calling pfnFlush is OK
- FB_UNLOCK() must be after the call to pfnFlush, so fb_FileFlush retains locks until after fflush() call
  • Loading branch information
jayrm committed Sep 22, 2019
1 parent 4dddf16 commit c958fbe
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/rtlib/file_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ FBCALL int fb_FileFlush( int fnum )
{
FB_FILE *handle;

int res;

FB_LOCK();
handle = FB_FILE_TO_HANDLE(fnum);

Expand All @@ -16,12 +18,6 @@ FB_FILE *handle;
return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
}

if (handle->type != FB_FILE_TYPE_NORMAL)
{
FB_UNLOCK();
return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
}

if (handle->access == FB_FILE_ACCESS_READ)
{
FB_UNLOCK();
Expand All @@ -30,12 +26,15 @@ FB_FILE *handle;

if( handle->hooks && handle->hooks->pfnFlush )
{
FB_UNLOCK();
return handle->hooks->pfnFlush( handle );
res = handle->hooks->pfnFlush( handle );
}
else
{
FB_UNLOCK();
return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
}

FB_UNLOCK();

return res;

}

0 comments on commit c958fbe

Please sign in to comment.