From 02067ed44f2f0a9de33535dbb4080eca5a631273 Mon Sep 17 00:00:00 2001 From: a7301c Date: Thu, 30 Apr 2020 11:07:23 -0500 Subject: [PATCH] Fix complilation error after removing -fno-builtin The complication error i observed after remove -fno-builtin in kernel with commit: 6af03f4 Makefile: Remove -fno-builtin cflag ++++ kernel/msm-4.19/../../motorola/kernel/modules/drivers/misc/utag/utags.c:1805:45: warning: size argument in 'strlcpy' call appears to be size of the source; expec ted the size of the destination [-Wstrlcpy-strlcat-size] ++++ Change-Id: I68144bce14af6944e1b4d8c225d1ad04203aefa5 Signed-off-by: a7301c Reviewed-on: https://gerrit.mot.com/1545924 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Submit-Approved: Jira Key Tested-by: Jira Key Reviewed-by: Ryan Lattrel --- drivers/misc/utag/utags.c | 6 ++++-- drivers/mmi_info/mmi_info_main.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/misc/utag/utags.c b/drivers/misc/utag/utags.c index 1fac16ebbd51..262c6da26c07 100644 --- a/drivers/misc/utag/utags.c +++ b/drivers/misc/utag/utags.c @@ -1789,6 +1789,7 @@ static int utag_get_bootarg(char *key, char **value) char *kvpair = NULL; int err = 1; struct device_node *n = of_find_node_by_path("/chosen"); + size_t bootargs_ptr_len = 0; if (n == NULL) goto err; @@ -1796,13 +1797,14 @@ static int utag_get_bootarg(char *key, char **value) if (of_property_read_string(n, "bootargs", &bootargs_ptr) != 0) goto err_putnode; + bootargs_ptr_len = strlen(bootargs_ptr); if (!bootargs_str) { /* Following operations need a non-const version of bootargs */ - bootargs_str = kzalloc(strlen(bootargs_ptr) + 1, GFP_KERNEL); + bootargs_str = kzalloc(bootargs_ptr_len + 1, GFP_KERNEL); if (!bootargs_str) goto err_putnode; } - strlcpy(bootargs_str, bootargs_ptr, strlen(bootargs_ptr) + 1); + strlcpy(bootargs_str, bootargs_ptr, bootargs_ptr_len + 1); idx = strnstr(bootargs_str, key, strlen(bootargs_str)); if (idx) { diff --git a/drivers/mmi_info/mmi_info_main.c b/drivers/mmi_info/mmi_info_main.c index 24f8a9d5c407..0dcfe678b536 100644 --- a/drivers/mmi_info/mmi_info_main.c +++ b/drivers/mmi_info/mmi_info_main.c @@ -28,6 +28,7 @@ int mmi_get_bootarg(char *key, char **value) char *kvpair = NULL; int err = 1; struct device_node *n = of_find_node_by_path("/chosen"); + size_t bootargs_tmp_len = 0; if (n == NULL) goto err; @@ -35,15 +36,16 @@ int mmi_get_bootarg(char *key, char **value) if (of_property_read_string(n, "bootargs", &bootargs_tmp) != 0) goto putnode; + bootargs_tmp_len = strlen(bootargs_tmp); if (!bootargs_str) { /* The following operations need a non-const * version of bootargs */ - bootargs_str = kzalloc(strlen(bootargs_tmp) + 1, GFP_KERNEL); + bootargs_str = kzalloc(bootargs_tmp_len + 1, GFP_KERNEL); if (!bootargs_str) goto putnode; } - strlcpy(bootargs_str, bootargs_tmp, strlen(bootargs_tmp) + 1); + strlcpy(bootargs_str, bootargs_tmp, bootargs_tmp_len + 1); idx = strnstr(bootargs_str, key, strlen(bootargs_str)); if (idx) {