From patchwork Thu May 19 07:33:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 574321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33DDDC433EF for ; Thu, 19 May 2022 07:33:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231797AbiESHdm (ORCPT ); Thu, 19 May 2022 03:33:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234768AbiESHdh (ORCPT ); Thu, 19 May 2022 03:33:37 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7138993995 for ; Thu, 19 May 2022 00:33:35 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id q130so5205044ljb.5 for ; Thu, 19 May 2022 00:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1yuktspFNrt5rjI2kzGLngt2z3t8Z3KhsCnQp62xNRg=; b=PpMvb9vLCRNbJjwWDqpUhsyrLAsP3JdmHhc2qOJ0FHvml1OmBXSyPkwbrY2o3ZNEJe rnvDE40QT+vJoBjpsQvuoBYe6QpFD/ckHyOGp/3fZIwOBjnIFnJ4oUGLldo5MFHtUMUr 0DPXmPQTxl01e1ATP3FspsXFP2MoCrmsW2iRLMoQYnacPYyoe2en6+U+9GqtD8QN0gC4 tFwzON0dHDvtDTI0mNSgRsVQnZoPC6BnVWEqci3hpI2VLPogC4D3j88uIkUqC2seF8sz YHG/HiJsphdbz8VFCJuByVWlWqDp67cLPHgnq1ieHvl+F0E6U1lCxKxzQL+Dc+IjByH0 rIsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1yuktspFNrt5rjI2kzGLngt2z3t8Z3KhsCnQp62xNRg=; b=8PiXAzwFVbkN8smJixsNk7aaA1s7xnlKRGrM/UjpDZ3IChRq14OXenL8mIpPlysx6b fRdVVk3GAQnsw+AAeWXzzEpGiWw8gTEYkh2R5Q7l/UTxoO6loflJ0teCrdsO4XBmJP9m sIPnrM41OPPiamI7LIfj6ANQDEOKVp3fxc4OyLrUPVU0m2P/NNIeOsyz9vfJ6B7Vw1rA DpJ3DGa38DdZt5hdgtzz0FutQ6r+q7qtLICjnGVIHZrJzjsIbVwIMto1i8He/sVrJdgt HN9rc0M7uG2N/lpF5bpWr4DY1YMwjXoUBHl6qh7yzy8crrepRO/IAW3St4u0RzAccgJ3 UUMw== X-Gm-Message-State: AOAM533mFzmBQjqKZmruI2o6LTyiTw60pUjQZ4JNOYBnlYk7uGpmEXQm IRZLqs5eaIoCMNzTesPAcz825w== X-Google-Smtp-Source: ABdhPJzLdpHMqhVMYhLA7IMeAJT9C0ozOcKgRLPjTWSOI2XTkdxgw3y5UZ36wVtkQyYXaaCK8CLQBQ== X-Received: by 2002:a05:651c:505:b0:24f:5248:3018 with SMTP id o5-20020a05651c050500b0024f52483018mr1837332ljp.45.1652945613804; Thu, 19 May 2022 00:33:33 -0700 (PDT) Received: from krzk-bin.. (78-11-189-27.static.ip.netia.com.pl. [78.11.189.27]) by smtp.gmail.com with ESMTPSA id a16-20020a056512201000b0047255d21159sm187484lfb.136.2022.05.19.00.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 00:33:33 -0700 (PDT) From: Krzysztof Kozlowski To: Andy Gross , Bjorn Andersson , Mathieu Poirier , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephen Boyd , Krzysztof Kozlowski Subject: [PATCH v2 1/3] rpmsg: qcom: glink: replace strncpy() with strscpy_pad() Date: Thu, 19 May 2022 09:33:28 +0200 Message-Id: <20220519073330.7187-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The use of strncpy() is considered deprecated for NUL-terminated strings[1]. Replace strncpy() with strscpy_pad(), to keep existing pad-behavior of strncpy, similarly to commit 08de420a8014 ("rpmsg: glink: Replace strncpy() with strscpy_pad()"). This fixes W=1 warning: In function ‘qcom_glink_rx_close’, inlined from ‘qcom_glink_work’ at ../drivers/rpmsg/qcom_glink_native.c:1638:4: drivers/rpmsg/qcom_glink_native.c:1549:17: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] 1549 | strncpy(chinfo.name, channel->name, sizeof(chinfo.name)); [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings Signed-off-by: Krzysztof Kozlowski --- Changes since v1: 1. Split series per subsystem. --- drivers/rpmsg/qcom_glink_native.c | 2 +- drivers/rpmsg/qcom_smd.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 07586514991f..5bc5a0a6a8a7 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1546,7 +1546,7 @@ static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid) cancel_work_sync(&channel->intent_work); if (channel->rpdev) { - strncpy(chinfo.name, channel->name, sizeof(chinfo.name)); + strscpy_pad(chinfo.name, channel->name, sizeof(chinfo.name)); chinfo.src = RPMSG_ADDR_ANY; chinfo.dst = RPMSG_ADDR_ANY; diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 6ccfa12abd10..7c8c29f6c91d 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -1089,7 +1089,7 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel) /* Assign public information to the rpmsg_device */ rpdev = &qsdev->rpdev; - strncpy(rpdev->id.name, channel->name, RPMSG_NAME_SIZE); + strscpy_pad(rpdev->id.name, channel->name, RPMSG_NAME_SIZE); rpdev->src = RPMSG_ADDR_ANY; rpdev->dst = RPMSG_ADDR_ANY; @@ -1323,7 +1323,7 @@ static void qcom_channel_state_worker(struct work_struct *work) spin_unlock_irqrestore(&edge->channels_lock, flags); - strncpy(chinfo.name, channel->name, sizeof(chinfo.name)); + strscpy_pad(chinfo.name, channel->name, sizeof(chinfo.name)); chinfo.src = RPMSG_ADDR_ANY; chinfo.dst = RPMSG_ADDR_ANY; rpmsg_unregister_device(&edge->dev, &chinfo);