Skip to content

Commit

Permalink
usb: dwc3: debug: purge usage of strcat
Browse files Browse the repository at this point in the history
Now that buffer size is always passed around, we don't need to rely on
strcat anymore.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  • Loading branch information
Felipe Balbi committed Feb 5, 2019
1 parent 7790b35 commit 1381a51
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/usb/dwc3/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,21 +545,25 @@ static inline const char *dwc3_ep_event_string(char *str, size_t size,
status & DEPEVT_STATUS_TRANSFER_ACTIVE ?
" (Active)" : " (Not Active)");

len = strlen(str);

/* Control Endpoints */
if (epnum <= 1) {
int phase = DEPEVT_STATUS_CONTROL_PHASE(event->status);

switch (phase) {
case DEPEVT_STATUS_CONTROL_DATA:
strcat(str, " [Data Phase]");
snprintf(str + ret, size - ret,
" [Data Phase]");
break;
case DEPEVT_STATUS_CONTROL_STATUS:
strcat(str, " [Status Phase]");
snprintf(str + ret, size - ret,
" [Status Phase]");
}
}
break;
case DWC3_DEPEVT_RXTXFIFOEVT:
strcat(str, "FIFO");
snprintf(str + ret, size - ret, "FIFO");
break;
case DWC3_DEPEVT_STREAMEVT:
status = event->status;
Expand All @@ -571,13 +575,13 @@ static inline const char *dwc3_ep_event_string(char *str, size_t size,
break;
case DEPEVT_STREAMEVT_NOTFOUND:
default:
strcat(str, " Stream Not Found");
snprintf(str + ret, size - ret, " Stream Not Found");
break;
}

break;
case DWC3_DEPEVT_EPCMDCMPLT:
strcat(str, "Endpoint Command Complete");
snprintf(str + ret, size - ret, "Endpoint Command Complete");
break;
default:
snprintf(str, size, "UNKNOWN");
Expand Down

0 comments on commit 1381a51

Please sign in to comment.