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





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux