Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d1d31dd authored by Markus Elfring's avatar Markus Elfring Committed by Ulf Hansson
Browse files

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: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 7f8e446b
Loading
Loading
Loading
Loading
+10 −12
Original line number Original line Diff line number Diff line
@@ -1246,12 +1246,8 @@ static void __download_offload_pseudocode(struct vub300_mmc_host *vub300,
						USB_RECIP_DEVICE, 0x0000, 0x0000,
						USB_RECIP_DEVICE, 0x0000, 0x0000,
						xfer_buffer, xfer_length, HZ);
						xfer_buffer, xfer_length, HZ);
			kfree(xfer_buffer);
			kfree(xfer_buffer);
			if (retval < 0) {
			if (retval < 0)
				strncpy(vub300->vub_name,
				goto copy_error_message;
					"SDIO pseudocode download failed",
					sizeof(vub300->vub_name));
				return;
			}
		} else {
		} else {
			dev_err(&vub300->udev->dev,
			dev_err(&vub300->udev->dev,
				"not enough memory for xfer buffer to send"
				"not enough memory for xfer buffer to send"
@@ -1293,12 +1289,8 @@ static void __download_offload_pseudocode(struct vub300_mmc_host *vub300,
						USB_RECIP_DEVICE, 0x0000, 0x0000,
						USB_RECIP_DEVICE, 0x0000, 0x0000,
						xfer_buffer, xfer_length, HZ);
						xfer_buffer, xfer_length, HZ);
			kfree(xfer_buffer);
			kfree(xfer_buffer);
			if (retval < 0) {
			if (retval < 0)
				strncpy(vub300->vub_name,
				goto copy_error_message;
					"SDIO pseudocode download failed",
					sizeof(vub300->vub_name));
				return;
			}
		} else {
		} else {
			dev_err(&vub300->udev->dev,
			dev_err(&vub300->udev->dev,
				"not enough memory for xfer buffer to send"
				"not enough memory for xfer buffer to send"
@@ -1351,6 +1343,12 @@ static void __download_offload_pseudocode(struct vub300_mmc_host *vub300,
			sizeof(vub300->vub_name));
			sizeof(vub300->vub_name));
		return;
		return;
	}
	}

	return;

copy_error_message:
	strncpy(vub300->vub_name, "SDIO pseudocode download failed",
		sizeof(vub300->vub_name));
}
}


/*
/*