Skip to contentSkip to conversation

Use strcpy for RandR output property names

PATCH In review Michel Dänzer 2 participants 2 messages Jul 23, 2018 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use strcpy for RandR output property names

From: Michel Dänzer <[email protected]>

Instead of strncpy with the string length. Avoids new warnings with GCC 8:

../../src/drmmode_display.c: In function ‘drmmode_output_create_resources’:
../../src/drmmode_display.c:2240:2: warning: ‘strncpy’ output truncated before terminating nul copying 8 bytes from a string of the same length [-Wstringop-truncation]
strncpy(tearfree_prop->name, "TearFree", 8);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/drmmode_display.c:2244:2: warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
strncpy(tearfree_prop->enums[0].name, "off", 3);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/drmmode_display.c:2245:2: warning: ‘strncpy’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Wstringop-truncation]
strncpy(tearfree_prop->enums[1].name, "on", 2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/drmmode_display.c:2247:2: warning: ‘strncpy’ output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]
strncpy(tearfree_prop->enums[2].name, "auto", 4);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---
 src/drmmode_display.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
src/drmmode_display.c +4 -4
index b3e754005..92f58c157 100644
@@ -2211,14 +2211,14 @@ static void drmmode_output_create_resources(xf86OutputPtr output)
 	/* Userspace-only property for TearFree */
 	tearfree_prop = calloc(1, sizeof(*tearfree_prop));
 	tearfree_prop->flags = DRM_MODE_PROP_ENUM;
-	strncpy(tearfree_prop->name, "TearFree", 8);
+	strcpy(tearfree_prop->name, "TearFree");
 	tearfree_prop->count_enums = 3;
 	tearfree_prop->enums = calloc(tearfree_prop->count_enums,
 				      sizeof(*tearfree_prop->enums));
-	strncpy(tearfree_prop->enums[0].name, "off", 3);
-	strncpy(tearfree_prop->enums[1].name, "on", 2);
+	strcpy(tearfree_prop->enums[0].name, "off");
+	strcpy(tearfree_prop->enums[1].name, "on");
 	tearfree_prop->enums[1].value = 1;
-	strncpy(tearfree_prop->enums[2].name, "auto", 4);
+	strcpy(tearfree_prop->enums[2].name, "auto");
 	tearfree_prop->enums[2].value = 2;
 	drmmode_output->props[j].mode_prop = tearfree_prop;
 	drmmode_output->props[j].value = info->tear_free;
Signature · 6 lines
2.18.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180723164511.21547-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#2 lore raw

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Michel Dänzer <[email protected]>
Sent: Monday, July 23, 2018 12:45:11 PM
To: [email protected]
Subject: [PATCH xf86-video-amdgpu] Use strcpy for RandR output property names

From: Michel Dänzer <[email protected]>

Instead of strncpy with the string length. Avoids new warnings with GCC 8:

../../src/drmmode_display.c: In function ‘drmmode_output_create_resources’:
../../src/drmmode_display.c:2240:2: warning: ‘strncpy’ output truncated before terminating nul copying 8 bytes from a string of the same length [-Wstringop-truncation]
strncpy(tearfree_prop->name, "TearFree", 8);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/drmmode_display.c:2244:2: warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
strncpy(tearfree_prop->enums[0].name, "off", 3);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/drmmode_display.c:2245:2: warning: ‘strncpy’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Wstringop-truncation]
strncpy(tearfree_prop->enums[1].name, "on", 2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/drmmode_display.c:2247:2: warning: ‘strncpy’ output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]
strncpy(tearfree_prop->enums[2].name, "auto", 4);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---
 src/drmmode_display.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
src/drmmode_display.c +4 -4
index b3e754005..92f58c157 100644
@@ -2211,14 +2211,14 @@ static void drmmode_output_create_resources(xf86OutputPtr output)
         /* Userspace-only property for TearFree */
         tearfree_prop = calloc(1, sizeof(*tearfree_prop));
         tearfree_prop->flags = DRM_MODE_PROP_ENUM;
-       strncpy(tearfree_prop->name, "TearFree", 8);
+       strcpy(tearfree_prop->name, "TearFree");
         tearfree_prop->count_enums = 3;
         tearfree_prop->enums = calloc(tearfree_prop->count_enums,
                                       sizeof(*tearfree_prop->enums));
-       strncpy(tearfree_prop->enums[0].name, "off", 3);
-       strncpy(tearfree_prop->enums[1].name, "on", 2);
+       strcpy(tearfree_prop->enums[0].name, "off");
+       strcpy(tearfree_prop->enums[1].name, "on");
         tearfree_prop->enums[1].value = 1;
-       strncpy(tearfree_prop->enums[2].name, "auto", 4);
+       strcpy(tearfree_prop->enums[2].name, "auto");
         tearfree_prop->enums[2].value = 2;
         drmmode_output->props[j].mode_prop = tearfree_prop;
         drmmode_output->props[j].value = info->tear_free;

--
2.18.0

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx