mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-03-14 04:01:06 +00:00
Check return code from mmap() properly.
This commit is contained in:
parent
a254c348e7
commit
ba644e67c7
1 changed files with 5 additions and 2 deletions
|
@ -38,6 +38,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
|
|
||||||
|
#ifndef MAP_FAILED
|
||||||
|
# define MAP_FAILED ((void *) -1)
|
||||||
|
#endif
|
||||||
|
|
||||||
int audio_fd;
|
int audio_fd;
|
||||||
int snd_inited;
|
int snd_inited;
|
||||||
|
|
||||||
|
@ -140,8 +144,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)
|
if (shm->buffer == MAP_FAILED) {
|
||||||
{
|
|
||||||
perror("/dev/dsp");
|
perror("/dev/dsp");
|
||||||
Con_Printf("Could not mmap /dev/dsp\n");
|
Con_Printf("Could not mmap /dev/dsp\n");
|
||||||
close(audio_fd);
|
close(audio_fd);
|
||||||
|
|
Loading…
Reference in a new issue