Re: [PATCH] loop: Add sanity check for read/write_iter

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

 



On Fri, 25 Apr 2025 06:06:51 +0200, Zhu Yanjun wrote:
> > diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> > index 674527d770dc..4f968e3071ed 100644
> > --- a/drivers/block/loop.c
> > +++ b/drivers/block/loop.c
> > @@ -449,10 +449,15 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
> >       cmd->iocb.ki_flags = IOCB_DIRECT;
> >       cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
> >
> > -     if (rw == ITER_SOURCE)
> > -             ret = file->f_op->write_iter(&cmd->iocb, &iter);
> > -     else
> > -             ret = file->f_op->read_iter(&cmd->iocb, &iter);
> > +     ret = 0;
> > +     if (rw == ITER_SOURCE) {
> > +             if (likely(file->f_op->write_iter))
> > +                     ret = file->f_op->write_iter(&cmd->iocb, &iter);
> > +     }
> > +     else {
> > +             if (likely(file->f_op->read_iter))
> 
> "else if" is better?
There is nothing wrong with writing it this way logically, but it will
destroy the clarity of the original context regarding the read/write logical
relationship.




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux