soc: qcom: cmd-db: replace strncpy() with strscpy_pad()
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Thu, 19 May 2022 07:33:00 +0000 (09:33 +0200)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Sun, 26 Jun 2022 03:05:31 +0000 (22:05 -0500)
The use of strncpy() is considered deprecated for NUL-terminated
strings[1].  Replace strncpy() with strscpy_pad(), to keep existing
pad-behavior of strncpy.  This fixes W=1 warning:

  drivers/soc/qcom/cmd-db.c: In function ‘cmd_db_get_header.part.0’:
  drivers/soc/qcom/cmd-db.c:151:9: warning: ‘strncpy’ specified bound 8 equals destination size [-Wstringop-truncation]
    151 |         strncpy(query, id, sizeof(query));

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220519073301.7072-1-krzysztof.kozlowski@linaro.org
drivers/soc/qcom/cmd-db.c

index dd87201..c5137c2 100644 (file)
@@ -148,7 +148,7 @@ static int cmd_db_get_header(const char *id, const struct entry_header **eh,
                return ret;
 
        /* Pad out query string to same length as in DB */
-       strncpy(query, id, sizeof(query));
+       strscpy_pad(query, id, sizeof(query));
 
        for (i = 0; i < MAX_SLV_ID; i++) {
                rsc_hdr = &cmd_db_header->header[i];