checked sources of xorg-server 1.7.0 with static code analysis tool cppcheck

Michel Dänzer michel at daenzer.net
Fri Oct 2 16:17:17 PDT 2009


On Fri, 2009-10-02 at 23:10 +0200, Martin Ettl wrote: 
> 
> diff --git a/exa/exa_classic.c b/exa/exa_classic.c
> index 1eff570..c9c7534 100644
> --- a/exa/exa_classic.c
> +++ b/exa/exa_classic.c
> @@ -144,14 +144,14 @@ Bool
>  exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int
> height, int depth,
>                       int bitsPerPixel, int devKind, pointer pPixData)
>  {
> +    if (!pPixmap)
> +        return FALSE;
> +
>      ScreenPtr pScreen = pPixmap->drawable.pScreen;
>      ExaScreenPrivPtr pExaScr;
>      ExaPixmapPrivPtr pExaPixmap;
>      Bool ret;
>  
> -    if (!pPixmap)
> -        return FALSE;
> -
>      pExaScr = ExaGetScreenPriv(pScreen);
>      pExaPixmap = ExaGetPixmapPriv(pPixmap);
>  
> diff --git a/exa/exa_driver.c b/exa/exa_driver.c
> index 9703695..db885e5 100644
> --- a/exa/exa_driver.c
> +++ b/exa/exa_driver.c
> @@ -122,14 +122,14 @@ Bool
>  exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int
> height, int depth,
>                       int bitsPerPixel, int devKind, pointer pPixData)
>  {
> +    if (!pPixmap)
> +        return FALSE;
> +
>      ScreenPtr pScreen = pPixmap->drawable.pScreen;
>      ExaScreenPrivPtr pExaScr;
>      ExaPixmapPrivPtr pExaPixmap;
>      Bool ret;
>  
> -    if (!pPixmap)
> -        return FALSE;
> -
>      pExaScr = ExaGetScreenPriv(pScreen);
>      pExaPixmap = ExaGetPixmapPriv(pPixmap);
>  
> diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
> index 167ffa9..0b6f8d9 100644
> --- a/exa/exa_mixed.c
> +++ b/exa/exa_mixed.c
> @@ -104,14 +104,14 @@ Bool
>  exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height,
> int depth,
>                       int bitsPerPixel, int devKind, pointer pPixData)
>  {
> +    if (!pPixmap)
> +        return FALSE;
> +
>      ScreenPtr pScreen = pPixmap->drawable.pScreen;
>      ExaScreenPrivPtr pExaScr;
>      ExaPixmapPrivPtr pExaPixmap;
>      Bool ret, is_offscreen;
>  
> -    if (!pPixmap)
> -        return FALSE;
> -
>      pExaScr = ExaGetScreenPriv(pScreen);
>      pExaPixmap = ExaGetPixmapPriv(pPixmap);
>  

Mixing code and declarations is a C99 feature, and I'm not sure we
require a C99 compiler yet. I'm not sure that that these tests serve any
real purpose, they can probably just be removed.


-- 
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the xorg-devel mailing list