Re: [PATCH] staging: unisys: use common return path

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

 



Doing One Err style error handling is often a mistake but it's ok here.
Just choose a better label name, though.  "unlock".  I have seen several
bugs caused because people used the label name "err" instead of
"unlock".  Compare these two examples.

	spin_unlock();
err:
	return ret;

Do you see the bug?  Now look at this code:

	spin_unlock();
unlock:
	return ret;

Just from looking at those few lines you can see that the intent was
to unlock but instead it just returns.  In the first example, you need
to scroll to the start of the function and examine the context to see
what "err" was intended to do.  And you're not likely to even be
suspicious of the err label because do nothing labels with ambiguos
label names are very common.

I have seen at least three places where an ambiguously named label was
placed after the spin unlock instead of before, where it was intended.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux