Skip to content

Commit bfafd8a

Browse files
committed
USBHost: Calling memcpy() instead of memset()?
The two following memcpy() calls in USBEndpoint::init() are passing in a NULL pointer as the copy source location. memcpy(td_list_[0], 0, sizeof(HCTD)); memcpy(td_list_[1], 0, sizeof(HCTD)); I suspect that these were meant to be memset() calls instead so I switched them. In one of the places that I found where this method is called, USBHost::newEndpoint(), its passes in an array of HCTD objects which have already been cleared with similar memset() calls. I am therefore pretty certain that these were meant to be memset() calls but if all callers already guarantee that they are zeroed out then maybe the memset()s can be removed from USBEndpoint::init() anyway.
1 parent 8a6d5eb commit bfafd8a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libraries/USBHost/USBHost/USBEndpoint.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ void USBEndpoint::init(HCED * hced_, ENDPOINT_TYPE type_, ENDPOINT_DIRECTION dir
2727

2828
//TDs have been allocated by the host
2929
memcpy((HCTD**)td_list, td_list_, sizeof(HCTD*)*2); //TODO: Maybe should add a param for td_list size... at least a define
30-
memcpy(td_list_[0], 0, sizeof(HCTD));
31-
memcpy(td_list_[1], 0, sizeof(HCTD));
30+
memset(td_list_[0], 0, sizeof(HCTD));
31+
memset(td_list_[1], 0, sizeof(HCTD));
3232

3333
td_list[0]->ep = this;
3434
td_list[1]->ep = this;

0 commit comments

Comments
 (0)