提交 cf446f0d 编写于 作者: E Ed L. Cashin 提交者: Linus Torvalds

aoe: eliminate goto and improve readability

Adam Richter suggested eliminating this goto.
Signed-off-by: NEd L. Cashin <ecashin@coraid.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 468fc530
...@@ -194,12 +194,15 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off) ...@@ -194,12 +194,15 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
ulong flags; ulong flags;
n = (unsigned long) filp->private_data; n = (unsigned long) filp->private_data;
switch (n) { if (n != MINOR_ERR)
case MINOR_ERR: return -EFAULT;
spin_lock_irqsave(&emsgs_lock, flags); spin_lock_irqsave(&emsgs_lock, flags);
loop:
for (;;) {
em = emsgs + emsgs_head_idx; em = emsgs + emsgs_head_idx;
if ((em->flags & EMFL_VALID) == 0) { if ((em->flags & EMFL_VALID) != 0)
break;
if (filp->f_flags & O_NDELAY) { if (filp->f_flags & O_NDELAY) {
spin_unlock_irqrestore(&emsgs_lock, flags); spin_unlock_irqrestore(&emsgs_lock, flags);
return -EAGAIN; return -EAGAIN;
...@@ -218,7 +221,6 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off) ...@@ -218,7 +221,6 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
spin_unlock_irqrestore(&emsgs_lock, flags); spin_unlock_irqrestore(&emsgs_lock, flags);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
goto loop;
} }
if (em->len > cnt) { if (em->len > cnt) {
spin_unlock_irqrestore(&emsgs_lock, flags); spin_unlock_irqrestore(&emsgs_lock, flags);
...@@ -237,9 +239,6 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off) ...@@ -237,9 +239,6 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
n = copy_to_user(buf, mp, len); n = copy_to_user(buf, mp, len);
kfree(mp); kfree(mp);
return n == 0 ? len : -EFAULT; return n == 0 ? len : -EFAULT;
default:
return -EFAULT;
}
} }
static const struct file_operations aoe_fops = { static const struct file_operations aoe_fops = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册