[Mesa-dev] [PATCH 2/3] glx: Fix two identical null check errors in driSet/GetInterval

Brian Paul brianp at vmware.com
Wed Dec 18 08:39:11 PST 2013


On 12/18/2013 06:58 AM, Juha-Pekka Heikkila wrote:
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
>   src/glx/dri_glx.c | 22 ++++++++++++++--------
>   1 file changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
> index 0b89e3e..91cccac 100644
> --- a/src/glx/dri_glx.c
> +++ b/src/glx/dri_glx.c
> @@ -747,13 +747,16 @@ static int
>   driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
>   {
>      struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
> -   struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
> +   struct dri_screen *psc;
>
> -   if (psc->swapControl != NULL && pdraw != NULL) {
> -      psc->swapControl->setSwapInterval(pdp->driDrawable, interval);
> -      return 0;
> -   }
> +   if (pdraw != NULL) {
> +      psc = (struct dri_screen *) pdraw->psc;
>
> +      if (psc->swapControl != NULL) {
> +         psc->swapControl->setSwapInterval(pdp->driDrawable, interval);
> +         return 0;
> +      }
> +   }
>      return GLX_BAD_CONTEXT;
>   }
>
> @@ -761,11 +764,14 @@ static int
>   driGetSwapInterval(__GLXDRIdrawable *pdraw)
>   {
>      struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
> -   struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
> +   struct dri_screen *psc;
>
> -   if (psc->swapControl != NULL && pdraw != NULL)
> -      return psc->swapControl->getSwapInterval(pdp->driDrawable);
> +   if (pdraw != NULL) {
> +      psc = (struct dri_screen *) pdraw->psc;
>
> +      if (psc->swapControl != NULL)
> +         return psc->swapControl->getSwapInterval(pdp->driDrawable);
> +   }
>      return 0;
>   }
>
>

The declaration of 'psc' could be moved into the if-block where it's used.

-Brian



More information about the mesa-dev mailing list