coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] df: use proper pointer size for xnrealloc


From: Pádraig Brady
Subject: Re: [PATCH] df: use proper pointer size for xnrealloc
Date: Wed, 16 Apr 2014 09:13:28 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 04/15/2014 10:06 PM, Bernhard Voelker wrote:
> * src/df.c (alloc_table_row): Use the size of char** to enlarge
> the table.  Spotted by Coverity.
> ---
>  src/df.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/df.c b/src/df.c
> index 3036c74..e763943 100644
> --- a/src/df.c
> +++ b/src/df.c
> @@ -290,7 +290,7 @@ static void
>  alloc_table_row (void)
>  {
>    nrows++;
> -  table = xnrealloc (table, nrows, sizeof (char *));
> +  table = xnrealloc (table, nrows, sizeof (char **));
>    table[nrows - 1] = xnmalloc (ncolumns, sizeof (char *));
>  }

So coverity says:

  CID 1191815 (#1 of 1): Wrong sizeof argument (SIZEOF_MISMATCH)
  suspicious_sizeof: Passing argument 8UL /* sizeof (char *) */ to function 
xnrealloc
  and then casting the return value to char *** is suspicious

The patch is good to get rid of the warning, but we're
just dealing with pointers here so there is no change to the code.
Hence I'd change the commit message to:

  maint: df: avoid sizeof(char**) static analysis warning

thanks!
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]