summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Ji <ji.luo@nxp.com>2018-01-25 14:48:23 +0800
committerLuo Ji <ji.luo@nxp.com>2018-01-25 19:38:54 +0800
commit638ec01fb9b267e6ab65e33552c178677f6258e9 (patch)
tree1deb9d43455d65ec542d316d4d7bb9921cff5c6e
parent9e74f978829f465b54a7fc189d306490399c816b (diff)
downloaduboot-imx-638ec01fb9b267e6ab65e33552c178677f6258e9.tar.gz
MA-11241 [Android] Use strlen() to calculate the string length
Calculate the string length with strlen() instead of hard code. Change-Id: I6028c249ca03f5d3d08225c528d3584e507c64b3 Signed-off-by: Luo Ji <ji.luo@nxp.com>
-rwxr-xr-xdrivers/usb/gadget/f_fastboot.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 9eb7fb646a..fa3d9cb47d 100755
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -2787,28 +2787,33 @@ static void cb_flashing(struct usb_ep *ep, struct usb_request *req)
FASTBOOT_BOOTLOADER_VBOOT_KEY,
strlen(FASTBOOT_BOOTLOADER_VBOOT_KEY))) {
strcpy(response, "OKAY");
- } else if (!strncmp(cmd + len - 15, "unlock_critical", 15)) {
+ } else if (!strncmp(cmd + len - strlen("unlock_critical"),
+ "unlock_critical", strlen("unlock_critical"))) {
#else
- if (!strncmp(cmd + len - 15, "unlock_critical", 15)) {
+ if (!strncmp(cmd + len - strlen("unlock_critical"),
+ "unlock_critical", strlen("unlock_critical"))) {
#endif
strcpy(response, "OKAY");
- } else if (!strncmp(cmd + len - 13, "lock_critical", 13)) {
+ } else if (!strncmp(cmd + len - strlen("lock_critical"),
+ "lock_critical", strlen("lock_critical"))) {
strcpy(response, "OKAY");
- } else if (!strncmp(cmd + len - 6, "unlock", 6)) {
+ } else if (!strncmp(cmd + len - strlen("unlock"),
+ "unlock", strlen("unlock"))) {
printf("flashing unlock.\n");
status = do_fastboot_unlock(false);
if (status != FASTBOOT_LOCK_ERROR)
strcpy(response, "OKAY");
else
strcpy(response, "FAIL unlock device failed.");
- } else if (!strncmp(cmd + len - 4, "lock", 4)) {
+ } else if (!strncmp(cmd + len - strlen("lock"), "lock", strlen("lock"))) {
printf("flashing lock.\n");
status = do_fastboot_lock();
if (status != FASTBOOT_LOCK_ERROR)
strcpy(response, "OKAY");
else
strcpy(response, "FAIL lock device failed.");
- } else if (!strncmp(cmd + len - 18, "get_unlock_ability", 18)) {
+ } else if (!strncmp(cmd + len - strlen("get_unlock_ability"),
+ "get_unlock_ability", strlen("get_unlock_ability"))) {
result = fastboot_lock_enable();
if (result == FASTBOOT_UL_ENABLE) {
fastboot_tx_write_more("INFO1");