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

Sergey Senozhatsky <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kernel.vger.linux-block
Message-ID <[email protected]>
On (26/08/03 22:12), Haoqin Huang wrote:
>  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;

If we want to be pedantic, then {} should also be added to the "if"
in this case.  And in other similar cases.

> +	else if (params->level < Z_DEFAULT_COMPRESSION ||
> +		 params->level > Z_BEST_COMPRESSION) {
> +		pr_err("deflate: invalid compression level %d\n", params->level);
> +		return -EINVAL;
> +	}
> +

[..]
> +	else if (params->level < 1 || params->level > LZ4HC_MAX_CLEVEL) {
> +		pr_err("lz4hc: invalid compression level %d\n", params->level);
> +		return -EINVAL;
> +	}

Let's add a small comment justifying/explaining that "1" constant?
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.