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 <a7301c@motorola.com>
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 <ryanl@motorola.com>
This commit is contained in:
a7301c 2020-04-30 11:07:23 -05:00 • committed by Yinjun Chen
commit 02067ed44f
2 changed files with 8 additions and 4 deletions

View file

@ -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) {

View file

@ -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) {