[PATCH] xf86RegisterRootWindowProperty is confused about xnfcalloc

Paulo Zanoni przanoni at gmail.com
Fri Dec 9 04:14:48 PST 2011


2011/12/8 Alan Coopersmith <alan.coopersmith at oracle.com>:
> It will never return NULL, so don't try to handle a NULL condition,
> since that just confuses programmers and static analyzers.
>
> It uses calloc, so all the allocated memory is cleared, so there's
> no point looping over the memory to manually initialize it NULL.
>
> And just because it's annoying, it doesn't need to be the only
> place in this file to do if (NULL==...) instead of if (... == NULL).
>
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---

xf86Helper.c:1737:9: warning: unused variable 'i' [-Wunused-variable]

With the variable declaration removed:
Reviewed-by: Paulo Zanoni <paulo.r.zanoni at intel.com>


>  hw/xfree86/common/xf86Helper.c |   10 +++-------
>  1 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
> index d99522c..054e9f1 100644
> --- a/hw/xfree86/common/xf86Helper.c
> +++ b/hw/xfree86/common/xf86Helper.c
> @@ -1775,15 +1775,11 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
>
>     DebugF("new property filled\n");
>
> -    if (NULL==xf86RegisteredPropertiesTable) {
> +    if (xf86RegisteredPropertiesTable == NULL) {
>       DebugF("creating xf86RegisteredPropertiesTable[] size %d\n",
>             xf86NumScreens);
> -      if ( NULL==(xf86RegisteredPropertiesTable=(RootWinPropPtr*)xnfcalloc(sizeof(RootWinProp),xf86NumScreens) )) {
> -       return BadAlloc;
> -      }
> -      for (i=0; i<xf86NumScreens; i++) {
> -       xf86RegisteredPropertiesTable[i] = NULL;
> -      }
> +      xf86RegisteredPropertiesTable =
> +         xnfcalloc(sizeof(RootWinProp), xf86NumScreens);
>     }
>
>     DebugF("xf86RegisteredPropertiesTable %p\n",
> --
> 1.7.3.2
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel



-- 
Paulo Zanoni


More information about the xorg-devel mailing list