Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH v2 1/2] soc: qcom: cmd-db: replace strncpy() with strscpy_pad()
@ 2022-05-19  7:33 Krzysztof Kozlowski
  2022-05-19  7:33 ` [PATCH v2 2/2] soc: qcom: correct kerneldoc Krzysztof Kozlowski
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2022-05-19  7:33 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, linux-arm-msm, linux-kernel
  Cc: Stephen Boyd, Krzysztof Kozlowski

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>

---

Changes since v1:
1. Split series per subsystem.
2. Add tag.
---
 drivers/soc/qcom/cmd-db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index dd872017f345..c5137c25d819 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -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];
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-28  9:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-19  7:33 [PATCH v2 1/2] soc: qcom: cmd-db: replace strncpy() with strscpy_pad() Krzysztof Kozlowski
2022-05-19  7:33 ` [PATCH v2 2/2] soc: qcom: correct kerneldoc Krzysztof Kozlowski
2022-06-20 18:38 ` [PATCH v2 1/2] soc: qcom: cmd-db: replace strncpy() with strscpy_pad() Krzysztof Kozlowski
2022-06-27 20:02 ` Bjorn Andersson
2022-06-27 23:06 ` Doug Anderson
2022-06-27 23:18   ` Doug Anderson
2022-06-28  9:52   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox