Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: vub300: Use common code in __download_offload_pseudocode()

Add a jump target so that a specific string copy operation is stored
only once at the end of this function implementation.
Replace two calls of the function "strncpy" by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Markus Elfring and committed by
Ulf Hansson
2d1d31dd 7f8e446b

+10 -12
+10 -12
drivers/mmc/host/vub300.c
··· 1246 1246 USB_RECIP_DEVICE, 0x0000, 0x0000, 1247 1247 xfer_buffer, xfer_length, HZ); 1248 1248 kfree(xfer_buffer); 1249 - if (retval < 0) { 1250 - strncpy(vub300->vub_name, 1251 - "SDIO pseudocode download failed", 1252 - sizeof(vub300->vub_name)); 1253 - return; 1254 - } 1249 + if (retval < 0) 1250 + goto copy_error_message; 1255 1251 } else { 1256 1252 dev_err(&vub300->udev->dev, 1257 1253 "not enough memory for xfer buffer to send" ··· 1289 1293 USB_RECIP_DEVICE, 0x0000, 0x0000, 1290 1294 xfer_buffer, xfer_length, HZ); 1291 1295 kfree(xfer_buffer); 1292 - if (retval < 0) { 1293 - strncpy(vub300->vub_name, 1294 - "SDIO pseudocode download failed", 1295 - sizeof(vub300->vub_name)); 1296 - return; 1297 - } 1296 + if (retval < 0) 1297 + goto copy_error_message; 1298 1298 } else { 1299 1299 dev_err(&vub300->udev->dev, 1300 1300 "not enough memory for xfer buffer to send" ··· 1343 1351 sizeof(vub300->vub_name)); 1344 1352 return; 1345 1353 } 1354 + 1355 + return; 1356 + 1357 + copy_error_message: 1358 + strncpy(vub300->vub_name, "SDIO pseudocode download failed", 1359 + sizeof(vub300->vub_name)); 1346 1360 } 1347 1361 1348 1362 /*