Re: [PATCHv4 1/9] zram: Preparation for multi-zcomp support

From: Sergey Senozhatsky
Date: Wed Nov 02 2022 - 22:40:42 EST


On (22/11/02 13:13), Minchan Kim wrote:
[..]
> >
> > +static void zram_destroy_comps(struct zram *zram)
> > +{
> > + u32 idx;
> > +
> > + for (idx = 0; idx < ZRAM_MAX_ZCOMPS; idx++) {
> > + struct zcomp *comp = zram->comps[idx];
> > +
> > + zram->comps[idx] = NULL;
> > + if (IS_ERR_OR_NULL(comp))
>
> nit:
>
> Why don't you use just NULL check? I don't see any error setting
> for zram->comps(Maybe later patch? Will keep check)?

A defense measure. zcomp_create() returns err pointer, so here
I check for err and nil just in case (if somehow someday we
accidentally have err values stored in comps). It's cheap and
safer than NULL.