Re: [PATCH v5 3/4] zram: validate parameters in each backend's setup_params

Sergey Senozhatsky <[email protected]>
Newsgroups gmane.linux.block,gmane.linux.kernel
Message-ID <[email protected]>
On (26/08/03 22:12), Haoqin Huang wrote:
[..]
>  static int setup_params_842(struct zcomp_params *params)
>  {
> +	if (params->dict_sz) {
> +		pr_err("842: dictionary is not supported\n");
> +		return -EOPNOTSUPP;
> +	}
> +	if (params->level != ZCOMP_PARAM_NOT_SET) {
> +		pr_err("842: compression level is not supported\n");
> +		return -EOPNOTSUPP;
> +	}
>  	return 0;
>  }
[..]
>  static int deflate_setup_params(struct zcomp_params *params)
>  {
> +	if (params->dict_sz) {
> +		pr_err("deflate: dictionary is not supported\n");
> +		return -EOPNOTSUPP;
> +	}
> +
>  	if (params->level == ZCOMP_PARAM_NOT_SET)
>  		params->level = Z_DEFAULT_COMPRESSION;
> +	else if (params->level < Z_DEFAULT_COMPRESSION ||
> +		 params->level > Z_BEST_COMPRESSION) {
> +		pr_err("deflate: invalid compression level %d\n", params->level);
> +		return -EINVAL;
> +	}

This is purely optional, if you add per-backend pr_fmt() with backend
name e.g. "zstd:","lz4:" and so on (in a separate patch) then you don't
need to explicitly prefix every pr_err().
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.