[PATCH] linux: Propagate failure up to xf86MapVidMem (#18304)

walter harms wharms at bfs.de
Thu Apr 10 08:05:08 PDT 2014


why is it bad to exit here ? can the caller fix that issue ?

Am 10.04.2014 16:52, schrieb Adam Jackson:
> As opposed to calling FatalError.
> 
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
>  hw/xfree86/os-support/linux/lnx_video.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
> index 47f5abc..6a7c85f 100644
> --- a/hw/xfree86/os-support/linux/lnx_video.c
> +++ b/hw/xfree86/os-support/linux/lnx_video.c
> @@ -437,8 +437,9 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
>      fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
>  #endif

this looks strange, what fd is checked in case open(DEV_MEM,... is never called ?


>      if (fd < 0) {
> -        FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
> +        xf86ErrorF("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
>                     strerror(errno));
> +        return MAP_FAILED;
>      }
>  
>      if (flags & VIDMEM_READONLY)
> @@ -451,8 +452,9 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
>                  (off_t) realBase + BUS_BASE);
>      close(fd);
>      if (base == MAP_FAILED) {
> -        FatalError("xf86MapVidMem: Could not mmap framebuffer"
> +        xf86ErrorF("xf86MapVidMem: Could not mmap framebuffer"
>                     " (0x%08lx,0x%lx) (%s)\n", Base, Size, strerror(errno));
> +        return MAP_FAILED;
>      }

giving users a better error message is always a good idea.


just my 2 cents

re,
 wh

>      DebugF("base: %lx aligned base: %lx\n", base, (char *) base + alignOff);
>      return (char *) base + alignOff;


More information about the xorg-devel mailing list