powerpc: move from strlcpy with unused retval to strscpy
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 18 Aug 2022 20:59:46 +0000 (22:59 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 26 Aug 2022 01:02:20 +0000 (11:02 +1000)
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Link: https://lore.kernel.org/r/20220818205946.6336-1-wsa+renesas@sang-engineering.com
arch/powerpc/kernel/dt_cpu_ftrs.c
arch/powerpc/platforms/powernv/idle.c
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/platforms/pseries/hvcserver.c

index fc800a9fb2c4fb370b863a26b02e454c5b9663e3..c3fb9fdf5bd782e121571efd679e812a4540b2a5 100644 (file)
@@ -1099,7 +1099,7 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char
 
        prop = of_get_flat_dt_prop(node, "display-name", NULL);
        if (prop && strlen((char *)prop) != 0) {
-               strlcpy(dt_cpu_name, (char *)prop, sizeof(dt_cpu_name));
+               strscpy(dt_cpu_name, (char *)prop, sizeof(dt_cpu_name));
                cur_cpu_spec->cpu_name = dt_cpu_name;
        }
 
index 6f94b808dd39ac3d7369ee2fb6e3514d88d03bf7..6e6b3bd9c92ff066d3f273db6aac9aa382751b7f 100644 (file)
@@ -1411,7 +1411,7 @@ static int __init pnv_parse_cpuidle_dt(void)
                goto out;
        }
        for (i = 0; i < nr_idle_states; i++)
-               strlcpy(pnv_idle_states[i].name, temp_string[i],
+               strscpy(pnv_idle_states[i].name, temp_string[i],
                        PNV_IDLE_NAME_LEN);
        nr_pnv_idle_states = nr_idle_states;
        rc = 0;
index 9de9b2fb163d35cdce4f2e4fe797dc4f7813be0d..5c144c05cbfd81d470b80953294043a6a0704a71 100644 (file)
@@ -67,7 +67,7 @@ void pe_level_printk(const struct pnv_ioda_pe *pe, const char *level,
        vaf.va = &args;
 
        if (pe->flags & PNV_IODA_PE_DEV)
-               strlcpy(pfix, dev_name(&pe->pdev->dev), sizeof(pfix));
+               strscpy(pfix, dev_name(&pe->pdev->dev), sizeof(pfix));
        else if (pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))
                sprintf(pfix, "%04x:%02x     ",
                        pci_domain_nr(pe->pbus), pe->pbus->number);
index 96e18d3b2fcf5e53bd82afe00b9b684199f69111..d48c9c7ce10f1c036f6f08fb5672633dc0e20c88 100644 (file)
@@ -176,7 +176,7 @@ int hvcs_get_partner_info(uint32_t unit_address, struct list_head *head,
                        = (unsigned int)last_p_partition_ID;
 
                /* copy the Null-term char too */
-               strlcpy(&next_partner_info->location_code[0],
+               strscpy(&next_partner_info->location_code[0],
                        (char *)&pi_buff[2],
                        sizeof(next_partner_info->location_code));