Commit c824345
media: uvcvideo: Pass allocation size directly to uvc_alloc_urb_buffer
The uvc_alloc_urb_buffer() function implicitly depended on the
stream->urb_size field, which was set by its caller,
uvc_alloc_urb_buffers(). This implicit data flow makes the code harder
to follow.
More importantly, stream->urb_size was updated within the allocation
loop before the allocation was confirmed to be successful. If the
allocation failed, the stream object would be left with a urb_size that
doesn't correspond to valid, allocated URB buffers.
Refactor uvc_alloc_urb_buffer() to accept the buffer size as an explicit
argument. This makes the function's dependencies clear and improves the
robustness of the error handling path. The stream->urb_size is now set only
after a complete and successful allocation.
This is a pure refactoring and introduces no functional changes.
Signed-off-by: Ricardo Ribalda <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Tested-by: Itay Chamiel <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Laurent Pinchart <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>1 parent 40d3ac2 commit c824345
1 file changed
Lines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1771 | 1771 | | |
1772 | 1772 | | |
1773 | 1773 | | |
1774 | | - | |
| 1774 | + | |
| 1775 | + | |
1775 | 1776 | | |
1776 | 1777 | | |
1777 | 1778 | | |
1778 | | - | |
1779 | | - | |
| 1779 | + | |
| 1780 | + | |
1780 | 1781 | | |
1781 | 1782 | | |
1782 | 1783 | | |
| |||
1813 | 1814 | | |
1814 | 1815 | | |
1815 | 1816 | | |
1816 | | - | |
| 1817 | + | |
1817 | 1818 | | |
1818 | 1819 | | |
1819 | 1820 | | |
1820 | 1821 | | |
1821 | | - | |
| 1822 | + | |
| 1823 | + | |
1822 | 1824 | | |
1823 | 1825 | | |
1824 | 1826 | | |
| |||
1830 | 1832 | | |
1831 | 1833 | | |
1832 | 1834 | | |
| 1835 | + | |
1833 | 1836 | | |
1834 | 1837 | | |
1835 | 1838 | | |
1836 | 1839 | | |
1837 | 1840 | | |
1838 | 1841 | | |
1839 | 1842 | | |
1840 | | - | |
1841 | 1843 | | |
1842 | 1844 | | |
1843 | 1845 | | |
| |||
0 commit comments