On Tue, Apr 15, 2025 at 08:47:08PM -0700, Jakub Kicinski wrote:
On Sat, 12 Apr 2025 19:38:28 +0100 Qasim Ijaz wrote:
retval = usbnet_get_endpoints(dev, intf);
- if (retval)
- if (retval < 0) return retval;
This change is unnecessary ? Commit message speaks of control_write(), this is usbnet_get_endpoints().
So this change was done mainly for consistency with the other error checks in the function. Essentially in my one of my previous patches (https://lore.kernel.org/all/20250317175117.GI688833@kernel.org/) I was using "if (retval)" for error handling, however after Simon's recommendation to use "if (retval < 0)" I changed this. In this particular function I took Simons advice but then noticed that the usbnet_get_endpoints() check was still using "if (retval)" so I decided to make it the same as the others.
The behaviour is still the same regardless of it we do "if (retval < 0)" or "if (retval)" for checking usbnet_get_endpoints() since it returns 0 on success or negative on failure.
So in ch9200_bind:
In the first case of "if (retval)", if the usbnet_get_endpoints() function fails and returns negative then we execute this branch and it returns negative, if it succeeds with 0 then the ch9200_bind function continues.
In the second case of "if (retval < 0)", if the usbnet_get_endpoints() function fails and returns negative then we execute this branch and it returns negative, if it succeeds with 0 then ch9200_bind function continues.
If you like I can include this in the patch description for clarity or remove it entirely.