Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 794c10fa authored by Jörn Engel's avatar Jörn Engel Committed by James Bottomley
Browse files

[SCSI] sg: remove while (1) non-loop



The while (1) construct isn't actually a loop at all.  So let's not
pretent and obfuscate the code.

Signed-off-by: default avatarJoern Engel <joern@logfs.org>
Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent dddbf8d9
Loading
Loading
Loading
Loading
+22 −30
Original line number Diff line number Diff line
@@ -398,19 +398,15 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
			retval = -EAGAIN;
			goto free_old_hdr;
		}
		while (1) {
		retval = 0; /* following macro beats race condition */
		__wait_event_interruptible(sfp->read_wait,
			(sdp->detached ||
				(srp = sg_get_rq_mark(sfp, req_pack_id))), 
				retval);
			(srp = sg_get_rq_mark(sfp, req_pack_id))), retval);
		if (sdp->detached) {
			retval = -ENODEV;
			goto free_old_hdr;
		}
			if (0 == retval)
				break;

		if (retval) {
			/* -ERESTARTSYS as signal hit process */
			goto free_old_hdr;
		}
@@ -801,25 +797,21 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
				 1, read_only, 1, &srp);
		if (result < 0)
			return result;
		while (1) {
		result = 0;	/* following macro to beat race condition */
		__wait_event_interruptible(sfp->read_wait,
				(srp->done || sdp->detached),
				result);
			(srp->done || sdp->detached), result);
		if (sdp->detached)
			return -ENODEV;
		write_lock_irq(&sfp->rq_list_lock);
		if (srp->done) {
			srp->done = 2;
			write_unlock_irq(&sfp->rq_list_lock);
				break;
			result = sg_new_read(sfp, p, SZ_SG_IO_HDR, srp);
			return (result < 0) ? result : 0;
		}
		srp->orphan = 1;
		write_unlock_irq(&sfp->rq_list_lock);
		return result;	/* -ERESTARTSYS because signal hit process */
		}
		result = sg_new_read(sfp, p, SZ_SG_IO_HDR, srp);
		return (result < 0) ? result : 0;
	case SG_SET_TIMEOUT:
		result = get_user(val, ip);
		if (result)