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

haoqin huang <[email protected]>
Newsgroups gmane.linux.block,gmane.linux.kernel
Message-ID <CAEjiKSn3q55VrsB3mufdA5q+MUUdrJQuSevqo3f_-3gEK=NLCQ@mail.gmail.com>
On Tue, Aug 4, 2026 at 1:48 PM Sergey Senozhatsky
<[email protected]> wrote:
>
> 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().

I considered adding pr_fmt, but the existing winbits message already
has "deflate" inline:

    pr_err("invalid deflate winbits: %d\n", wb);

which would become "deflate: invalid deflate winbits:" and look redundant.
I can add pr_fmt in a separate patch and clean that up to just
"invalid winbits %d" at the same time though, if you prefer.
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.