mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2024-11-29 07:02:08 +00:00
Check return code from mmap() properly.
This commit is contained in:
parent
8d8f0d617c
commit
04c438c55e
2 changed files with 18 additions and 14 deletions
|
@ -38,6 +38,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
# include <machine/soundcard.h>
|
# include <machine/soundcard.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAP_FAILED
|
||||||
|
# define MAP_FAILED ((void*)-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
static int audio_fd;
|
static int audio_fd;
|
||||||
static int snd_inited;
|
static int snd_inited;
|
||||||
|
|
||||||
|
@ -141,8 +145,7 @@ qboolean SNDDMA_Init(void)
|
||||||
shm->buffer = (unsigned char *) mmap(NULL, info.fragstotal
|
shm->buffer = (unsigned char *) mmap(NULL, info.fragstotal
|
||||||
* info.fragsize, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
|
* info.fragsize, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
|
||||||
|
|
||||||
// if (!shm->buffer || shm->buffer == (unsigned char *)-1)
|
if (shm->buffer == MAP_FAILED)
|
||||||
if (!shm->buffer)
|
|
||||||
{
|
{
|
||||||
perror("/dev/dsp");
|
perror("/dev/dsp");
|
||||||
Con_Printf("Could not mmap /dev/dsp\n");
|
Con_Printf("Could not mmap /dev/dsp\n");
|
||||||
|
|
|
@ -17,22 +17,23 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
// sys_sun.h -- Sun system driver
|
// sys_unix.c -- Unix system driver
|
||||||
|
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
#include "errno.h"
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stddef.h>
|
#ifndef MAP_FAILED
|
||||||
#include <sys/types.h>
|
# define MAP_FAILED ((void*)-1)
|
||||||
#include <fcntl.h>
|
#endif
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
qboolean isDedicated;
|
qboolean isDedicated;
|
||||||
|
|
||||||
|
@ -101,9 +102,9 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
sys_handles[i].hFile = f;
|
sys_handles[i].hFile = f;
|
||||||
sys_handles[i].nLen = filelength(f);
|
sys_handles[i].nLen = filelength(f);
|
||||||
sys_handles[i].nPos = 0;
|
sys_handles[i].nPos = 0;
|
||||||
sys_handles[i].pMap = mmap( 0, sys_handles[i].nLen, PROT_READ, MAP_SHARED, fileno( sys_handles[i].hFile ), 0 );
|
sys_handles[i].pMap = mmap(NULL, sys_handles[i].nLen, PROT_READ,
|
||||||
if (!sys_handles[i].pMap || (sys_handles[i].pMap == (char *)-1))
|
MAP_SHARED, fileno(sys_handles[i].hFile), 0 );
|
||||||
{
|
if (sys_handles[i].pMap == MAP_FAILED) {
|
||||||
printf( "mmap %s failed!", path );
|
printf( "mmap %s failed!", path );
|
||||||
sys_handles[i].pMap = NULL;
|
sys_handles[i].pMap = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue