From: <yang.yang29@zte.com.cn>
To: <deller@gmx.de>
Cc: <tony@atomide.com>, <b.zolnierkie@samsung.com>, <arnd@arndb.de>,
<yuzhe@nfschina.com>, <jiapeng.chong@linux.alibaba.com>,
<guozhengkui@vivo.com>, <linux-fbdev@vger.kernel.org>,
<linux-omap@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
<linux-kernel@vger.kernel.org>, <xu.panda@zte.com.cn>,
<yang.yang29@zte.com.cn>
Subject: [PATCH linux-next] fbdev: omap: use strscpy() to instead of strncpy()
Date: Wed, 28 Dec 2022 09:40:01 +0800 (CST) [thread overview]
Message-ID: <202212280940017919910@zte.com.cn> (raw)
From: Xu Panda <xu.panda@zte.com.cn>
The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL-terminated strings.
Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
---
drivers/video/fbdev/omap/omapfb_main.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/video/fbdev/omap/omapfb_main.c b/drivers/video/fbdev/omap/omapfb_main.c
index 17cda5765683..1f3df2055ff0 100644
--- a/drivers/video/fbdev/omap/omapfb_main.c
+++ b/drivers/video/fbdev/omap/omapfb_main.c
@@ -1447,7 +1447,7 @@ static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info)
info->fbops = &omapfb_ops;
info->flags = FBINFO_FLAG_DEFAULT;
- strncpy(fix->id, MODULE_NAME, sizeof(fix->id));
+ strscpy(fix->id, MODULE_NAME, sizeof(fix->id));
info->pseudo_palette = fbdev->pseudo_palette;
@@ -1573,8 +1573,7 @@ static int omapfb_find_ctrl(struct omapfb_device *fbdev)
fbdev->ctrl = NULL;
- strncpy(name, conf->lcd.ctrl_name, sizeof(name) - 1);
- name[sizeof(name) - 1] = '\0';
+ strscpy(name, conf->lcd.ctrl_name, sizeof(name));
if (strcmp(name, "internal") == 0) {
fbdev->ctrl = fbdev->int_ctrl;
--
2.15.2
next reply other threads:[~2022-12-28 1:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-28 1:40 yang.yang29 [this message]
2022-12-28 7:58 ` [PATCH linux-next] fbdev: omap: use strscpy() to instead of strncpy() Helge Deller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202212280940017919910@zte.com.cn \
--to=yang.yang29@zte.com.cn \
--cc=arnd@arndb.de \
--cc=b.zolnierkie@samsung.com \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=guozhengkui@vivo.com \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
--cc=xu.panda@zte.com.cn \
--cc=yuzhe@nfschina.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox