dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 03/18] drm_property: change strncpy+truncation to strlcpy
       [not found] <1531444483-17338-1-git-send-email-asmadeus@codewreck.org>
@ 2018-07-13  1:25 ` Dominique Martinet
  2018-07-13  1:25 ` [PATCH 04/18] nouveau: " Dominique Martinet
  1 sibling, 0 replies; 2+ messages in thread
From: Dominique Martinet @ 2018-07-13  1:25 UTC (permalink / raw)
  Cc: Dominique Martinet, Gustavo Padovan, Maarten Lankhorst,
	Sean Paul, David Airlie, dri-devel, linux-kernel

Using strlcpy fixes this new gcc warning:
    drivers/gpu/drm/drm_property.c: In function ‘drm_property_create’:
    drivers/gpu/drm/drm_property.c:125:2: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
      strncpy(property->name, name, DRM_PROP_NAME_LEN);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Generated by scripts/coccinelle/misc/strncpy_truncation.cocci

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---

Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the
first patch of the serie) for the motivation behind this patch

 drivers/gpu/drm/drm_property.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index cdb10f885a4f..8f0ccfa91f8b 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -122,8 +122,7 @@ struct drm_property *drm_property_create(struct drm_device *dev,
 	property->num_values = num_values;
 	INIT_LIST_HEAD(&property->enum_list);
 
-	strncpy(property->name, name, DRM_PROP_NAME_LEN);
-	property->name[DRM_PROP_NAME_LEN-1] = '\0';
+	strlcpy(property->name, name, DRM_PROP_NAME_LEN);
 
 	list_add_tail(&property->head, &dev->mode_config.property_list);
 
@@ -416,8 +415,7 @@ int drm_property_add_enum(struct drm_property *property,
 	if (!prop_enum)
 		return -ENOMEM;
 
-	strncpy(prop_enum->name, name, DRM_PROP_NAME_LEN);
-	prop_enum->name[DRM_PROP_NAME_LEN-1] = '\0';
+	strlcpy(prop_enum->name, name, DRM_PROP_NAME_LEN);
 	prop_enum->value = value;
 
 	property->values[index] = value;
-- 
2.17.1

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

* [PATCH 04/18] nouveau: change strncpy+truncation to strlcpy
       [not found] <1531444483-17338-1-git-send-email-asmadeus@codewreck.org>
  2018-07-13  1:25 ` [PATCH 03/18] drm_property: change strncpy+truncation to strlcpy Dominique Martinet
@ 2018-07-13  1:25 ` Dominique Martinet
  1 sibling, 0 replies; 2+ messages in thread
From: Dominique Martinet @ 2018-07-13  1:25 UTC (permalink / raw)
  Cc: Dominique Martinet, Ben Skeggs, David Airlie, dri-devel, nouveau,
	linux-kernel

Generated by scripts/coccinelle/misc/strncpy_truncation.cocci

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---

Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the
first patch of the serie) for the motivation behind this patch

 drivers/gpu/drm/nouveau/nvkm/core/firmware.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
index 058ff46b5f16..579eb17db9f4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
@@ -40,8 +40,7 @@ nvkm_firmware_get(struct nvkm_device *device, const char *fwname,
 	int i;
 
 	/* Convert device name to lowercase */
-	strncpy(cname, device->chip->name, sizeof(cname));
-	cname[sizeof(cname) - 1] = '\0';
+	strlcpy(cname, device->chip->name, sizeof(cname));
 	i = strlen(cname);
 	while (i) {
 		--i;
-- 
2.17.1

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

end of thread, other threads:[~2018-07-13  1:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1531444483-17338-1-git-send-email-asmadeus@codewreck.org>
2018-07-13  1:25 ` [PATCH 03/18] drm_property: change strncpy+truncation to strlcpy Dominique Martinet
2018-07-13  1:25 ` [PATCH 04/18] nouveau: " Dominique Martinet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).