Re: [PATCH v2] tsearch.3: Simplify type usage and remove unneeded casts

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

 



Hello Alex,

On 9/5/20 6:10 PM, Alejandro Colomar wrote:
> The type of `val` is `int **`, and it will work with tsearch()
> anyway because of implicit cast from `void *`, so declaring it as an
> `int **` simplifies the code.

Thanks, patch applied.

Cheers,

Michael

> Signed-off-by: Alejandro Colomar <colomar.6.4.3@xxxxxxxxx>
> ---
>  man3/tsearch.3 | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/man3/tsearch.3 b/man3/tsearch.3
> index 2e8403130..7b82d9bd3 100644
> --- a/man3/tsearch.3
> +++ b/man3/tsearch.3
> @@ -323,7 +323,7 @@ action(const void *nodep, VISIT which, int depth)
>  int
>  main(void)
>  {
> -    void *val;
> +    int **val;
>  
>      srand(time(NULL));
>      for (int i = 0; i < 12; i++) {
> @@ -332,7 +332,7 @@ main(void)
>          val = tsearch((void *) ptr, &root, compare);
>          if (val == NULL)
>              exit(EXIT_FAILURE);
> -        else if ((*(int **) val) != ptr)
> +        else if (*val != ptr)
>              free(ptr);
>      }
>      twalk(root, action);
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux