Re: [PATCH 2/5] trace-cmd: Make internal compression hooks more generic

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

 



On 2022-03-02 06:51:28 [+0200], Tzvetomir Stoyanov (VMware) wrote:
> Changed the prototypes of trace-cmd internal compression API to be more
> generic.
> 
> Suggested-by: Sebastian Andrzej Siewior <sebastian@xxxxxxxxxxxxx>
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx>

Acked-by: Sebastian Andrzej Siewior <sebastian@xxxxxxxxxxxxx>

> diff --git a/lib/trace-cmd/trace-compress-zlib.c b/lib/trace-cmd/trace-compress-zlib.c
> index 8b9758c9..41342597 100644
> --- a/lib/trace-cmd/trace-compress-zlib.c
> +++ b/lib/trace-cmd/trace-compress-zlib.c
> @@ -13,19 +13,17 @@
>  #define __ZLIB_NAME		"zlib"
>  #define __ZLIB_WEIGTH		10
>  
> -static int zlib_compress(const char *in, unsigned int in_bytes,
> -			 char *out, unsigned int *out_bytes)
> +static int zlib_compress(const void *in, int in_bytes, void *out, int out_bytes)
>  {
> -	unsigned long out_size = *out_bytes;
> +	unsigned long obytes = out_bytes;
>  	int ret;
>  
> -	ret = compress2((unsigned char *)out, &out_size,
> +	ret = compress2((unsigned char *)out, &obytes,
>  			(unsigned char *)in, (unsigned long)in_bytes, Z_BEST_COMPRESSION);
there is no need to cast to or from void *, this works always.

> -	*out_bytes = out_size;
>  	errno = 0;
>  	switch (ret) {
>  	case Z_OK:
> -		return 0;
> +		return obytes;
>  	case Z_BUF_ERROR:
>  		errno = -ENOBUFS;
>  		break;



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux