Browse Source

usb: dwc3: debug: purge usage of strcat

commit 1381a5113caf764f090b912b478663275e7b999e upstream.

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>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Felipe Balbi 6 years ago
parent
commit
517e89ed15
1 changed files with 9 additions and 5 deletions
  1. 9 5
      drivers/usb/dwc3/debug.h

+ 9 - 5
drivers/usb/dwc3/debug.h

@@ -545,21 +545,25 @@ static inline const char *dwc3_ep_event_string(char *str, size_t size,
 				status & DEPEVT_STATUS_TRANSFER_ACTIVE ?
 				status & DEPEVT_STATUS_TRANSFER_ACTIVE ?
 				" (Active)" : " (Not Active)");
 				" (Active)" : " (Not Active)");
 
 
+		len = strlen(str);
+
 		/* Control Endpoints */
 		/* Control Endpoints */
 		if (epnum <= 1) {
 		if (epnum <= 1) {
 			int phase = DEPEVT_STATUS_CONTROL_PHASE(event->status);
 			int phase = DEPEVT_STATUS_CONTROL_PHASE(event->status);
 
 
 			switch (phase) {
 			switch (phase) {
 			case DEPEVT_STATUS_CONTROL_DATA:
 			case DEPEVT_STATUS_CONTROL_DATA:
-				strcat(str, " [Data Phase]");
+				snprintf(str + ret, size - ret,
+						" [Data Phase]");
 				break;
 				break;
 			case DEPEVT_STATUS_CONTROL_STATUS:
 			case DEPEVT_STATUS_CONTROL_STATUS:
-				strcat(str, " [Status Phase]");
+				snprintf(str + ret, size - ret,
+						" [Status Phase]");
 			}
 			}
 		}
 		}
 		break;
 		break;
 	case DWC3_DEPEVT_RXTXFIFOEVT:
 	case DWC3_DEPEVT_RXTXFIFOEVT:
-		strcat(str, "FIFO");
+		snprintf(str + ret, size - ret, "FIFO");
 		break;
 		break;
 	case DWC3_DEPEVT_STREAMEVT:
 	case DWC3_DEPEVT_STREAMEVT:
 		status = event->status;
 		status = event->status;
@@ -571,13 +575,13 @@ static inline const char *dwc3_ep_event_string(char *str, size_t size,
 			break;
 			break;
 		case DEPEVT_STREAMEVT_NOTFOUND:
 		case DEPEVT_STREAMEVT_NOTFOUND:
 		default:
 		default:
-			strcat(str, " Stream Not Found");
+			snprintf(str + ret, size - ret, " Stream Not Found");
 			break;
 			break;
 		}
 		}
 
 
 		break;
 		break;
 	case DWC3_DEPEVT_EPCMDCMPLT:
 	case DWC3_DEPEVT_EPCMDCMPLT:
-		strcat(str, "Endpoint Command Complete");
+		snprintf(str + ret, size - ret, "Endpoint Command Complete");
 		break;
 		break;
 	default:
 	default:
 		snprintf(str, size, "UNKNOWN");
 		snprintf(str, size, "UNKNOWN");