Re: [PATCH][next] scsi: scsi_debug: remove a redundant assignment to variable ret

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

 



Generally, functions which report the number of bytes copied are an anti-pattern.

	bytes = copied();
	if (bytes < 0)
		return bytes;  <-- forgot to handle partial copies

	bytes = copied();
	if (bytes < 0 || bytes != total)
		return bytes;  <-- forgot the error code for partial copies

	bytes = copied();
	if (bytes < sizeof())  <-- negative error codes type promoted to positive
		return -EIO;

We've seen subsystems move away from this.  Other subsystems are like "Ugh.
Updating all the callers is a headache.  Let's either report that everything
copied or a negative error code, but not the partial bytes."  Now the first
two examples above magically work.

regards,
dan carpenter





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux