Skip to contentSkip to conversation

Use PATH_MAX to fix some sprintf-into-short-buffers warnings.

PATCH In review Eric Anholt 3 participants 7 messages Sep 3, 2017 – Sep 5, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Use PATH_MAX to fix some sprintf-into-short-buffers warnings.

---

This little series cleans up many compiler warnings I saw when testing danvet's meson branch.

 lib/igt_debugfs.c       | 4 ++--
 lib/igt_sysfs.c         | 4 ++--
 tests/kms_hdmi_inject.c | 2 +-
 tests/pm_rpm.c          | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)
lib/igt_debugfs.c +2 -2
index 090b56e03555..63183e57229b 100644
@@ -491,7 +491,7 @@ static void igt_pipe_crc_reset(int drm_fd)
 	}
 
 	while ((dirent = readdir(dir))) {
-		char buf[128];
+		char buf[PATH_MAX];
 
 		if (strcmp(dirent->d_name, "crtc-") != 0)
 			continue;
@@ -525,7 +525,7 @@ static void igt_pipe_crc_reset(int drm_fd)
 static void pipe_crc_exit_handler(int sig)
 {
 	struct dirent *dirent;
-	char buf[128];
+	char buf[PATH_MAX];
 	DIR *dir;
 	int fd;
 
lib/igt_sysfs.c +2 -2
index 15ed34be0088..9227e374bf44 100644
@@ -192,7 +192,7 @@ int igt_sysfs_open_parameters(int device)
 	if (params < 0) { /* builtin? */
 		drm_version_t version;
 		char name[32] = "";
-		char path[128];
+		char path[PATH_MAX];
 
 		memset(&version, 0, sizeof(version));
 		version.name_len = sizeof(name);
@@ -499,7 +499,7 @@ void kick_fbcon(bool enable)
 		return;
 
 	while ((de = readdir(dir))) {
-		char buf[128];
+		char buf[PATH_MAX];
 		int fd, len;
 
 		if (strncmp(de->d_name, "vtcon", 5))
tests/kms_hdmi_inject.c +1 -1
index cb916acec3c1..22570a4b637a 100644
@@ -170,7 +170,7 @@ eld_is_valid(void)
 			continue;
 
 		while ((snd_hda = readdir(dir))) {
-			char fpath[128];
+			char fpath[PATH_MAX];
 
 			if (*snd_hda->d_name == '.' ||
 			    strstr(snd_hda->d_name, "eld") == 0)
tests/pm_rpm.c +2 -2
index 47c9f1143484..9e8cf79b5128 100644
@@ -594,14 +594,14 @@ static int count_i2c_valid_edids(void)
 	DIR *dir;
 
 	struct dirent *dirent;
-	char full_name[32];
+	char full_name[PATH_MAX];
 
 	dir = opendir("/dev/");
 	igt_assert(dir);
 
 	while ((dirent = readdir(dir))) {
 		if (strncmp(dirent->d_name, "i2c-", 4) == 0) {
-			snprintf(full_name, 32, "/dev/%s", dirent->d_name);
+			sprintf(full_name, "/dev/%s", dirent->d_name);
 			fd = open(full_name, O_RDWR);
 			igt_assert_neq(fd, -1);
 			if (i2c_edid_is_valid(fd))
Signature · 6 lines
2.14.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/3 intel_watermark: Fix a warning about "const char" return being silly.

---
 tools/intel_watermark.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/intel_watermark.c +1 -1
index d98ef19b0abd..d8c784802c5b 100644
@@ -110,7 +110,7 @@ struct ilk_wm {
 	((((lo) >> (shift_lo)) & MASK(size_lo)) | \
 	 ((((hi) >> (shift_hi)) & MASK(size_hi)) << (size_lo)))
 
-static const char pipe_name(int pipe)
+static char pipe_name(int pipe)
 {
 	return 'A' + pipe;
 }
Signature · 6 lines
2.14.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/3 intel_display_poller: Fix truncation of a test name.

In reply to Eric Anholt
---
 tools/intel_display_poller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/intel_display_poller.c +1 -1
index c501c79d6367..828ca52b35ee 100644
@@ -901,7 +901,7 @@ static void poll_dsl_field(int pipe, uint32_t *min, uint32_t *max, const int cou
 
 static const char *test_name(enum test test, int pipe, int bit, bool test_pixel_count)
 {
-	static char str[32];
+	static char str[64];
 	const char *type = test_pixel_count ? "pixel" : "dsl";
 
 	switch (test) {
Signature · 6 lines
2.14.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

✓ Fi.CI.BAT: success for series starting with [1/3] Use PATH_MAX to fix some sprintf-into-short-buffers warnings.

In reply to Eric Anholt
== Series Details ==

== Series Details ==

Series: series starting with [1/3] Use PATH_MAX to fix some sprintf-into-short-buffers warnings.
URL : https://patchwork.freedesktop.org/series/29752/
State : success

== Summary ==

IGT patchset tested on top of latest successful build 5ce65a9a51f17e0183e3e4f8943981ee7b96cadd pm_rps: Changes in waitboost scenario

with latest DRM-Tip kernel build CI_DRM_3030
69c8e7a57ac9 drm-tip: 2017y-09m-02d-20h-25m-44s UTC integration manifest

Test kms_cursor_legacy:

        Subgroup basic-busy-flip-before-cursor-atomic:
                fail       -> PASS       (fi-snb-2600) fdo#100215
Test kms_flip:
        Subgroup basic-flip-vs-modeset:
                skip       -> PASS       (fi-skl-x1585l) fdo#101781

fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781

fi-bdw-5557u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:457s
fi-blb-e6850     total:288  pass:224  dwarn:1   dfail:0   fail:0   skip:63  time:366s
fi-bsw-n3050     total:288  pass:243  dwarn:0   dfail:0   fail:0   skip:45  time:562s
fi-bwr-2160      total:288  pass:184  dwarn:0   dfail:0   fail:0   skip:104 time:252s
fi-bxt-j4205     total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:521s
fi-byt-j1900     total:288  pass:254  dwarn:1   dfail:0   fail:0   skip:33  time:529s
fi-byt-n2820     total:288  pass:250  dwarn:1   dfail:0   fail:0   skip:37  time:516s
fi-elk-e7500     total:288  pass:230  dwarn:0   dfail:0   fail:0   skip:58  time:440s
fi-glk-2a        total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:613s
fi-hsw-4770      total:288  pass:263  dwarn:0   dfail:0   fail:0   skip:25  time:448s
fi-hsw-4770r     total:288  pass:263  dwarn:0   dfail:0   fail:0   skip:25  time:429s
fi-ilk-650       total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:422s
fi-ivb-3520m     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:510s
fi-ivb-3770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:474s
fi-kbl-7500u     total:288  pass:264  dwarn:1   dfail:0   fail:0   skip:23  time:517s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:602s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:602s
fi-pnv-d510      total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:525s
fi-skl-6260u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:466s
fi-skl-6700k     total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:534s
fi-skl-6770hq    total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:491s
fi-skl-gvtdvm    total:288  pass:266  dwarn:0   dfail:0   fail:0   skip:22  time:445s
fi-skl-x1585l    total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:505s
fi-snb-2520m     total:288  pass:251  dwarn:0   dfail:0   fail:0   skip:37  time:551s
fi-snb-2600      total:288  pass:250  dwarn:0   dfail:0   fail:0   skip:38  time:409s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_140/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✓ Fi.CI.IGT: success for series starting with [1/3] Use PATH_MAX to fix some sprintf-into-short-buffers warnings.

In reply to Eric Anholt
== Series Details ==

== Series Details ==

Series: series starting with [1/3] Use PATH_MAX to fix some sprintf-into-short-buffers warnings.
URL : https://patchwork.freedesktop.org/series/29752/
State : success

== Summary ==

Test kms_atomic_transition:

        Subgroup plane-use-after-nonblocking-unbind-fencing:
                fail       -> INCOMPLETE (shard-hsw) fdo#101847
Test kms_flip:
        Subgroup flip-vs-absolute-wf_vblank:
                pass       -> FAIL       (shard-hsw) fdo#100368
Test perf:
        Subgroup blocking:
                pass       -> FAIL       (shard-hsw) fdo#102252
Test kms_sysfs_edid_timing:
                warn       -> PASS       (shard-hsw) fdo#100047

fdo#101847 https://bugs.freedesktop.org/show_bug.cgi?id=101847
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047

shard-hsw total:2214 pass:1208 dwarn:0 dfail:0 fail:16 skip:988 time:9316s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_140/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
In reply to Eric Anholt
Quoted 5 lines · Eric Anholt

---

This little series cleans up many compiler warnings I saw when testing danvet's meson branch.

On the series: Reviewed-by: Daniel Vetter <[email protected]>

I've pulled in your other meson patches, they need minimal polish (e.g. my gcc doesn't have all the -W flags yours has, resulting in warnings about unknown flags without first checking for them).
-Daniel

Quoted 92 lines
 lib/igt_debugfs.c       | 4 ++--
 lib/igt_sysfs.c         | 4 ++--
 tests/kms_hdmi_inject.c | 2 +-
 tests/pm_rpm.c          | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)
lib/igt_debugfs.c +2 -2
index 090b56e03555..63183e57229b 100644
@@ -491,7 +491,7 @@ static void igt_pipe_crc_reset(int drm_fd)
 	}
 
 	while ((dirent = readdir(dir))) {
-		char buf[128];
+		char buf[PATH_MAX];
 
 		if (strcmp(dirent->d_name, "crtc-") != 0)
 			continue;
@@ -525,7 +525,7 @@ static void igt_pipe_crc_reset(int drm_fd)
 static void pipe_crc_exit_handler(int sig)
 {
 	struct dirent *dirent;
-	char buf[128];
+	char buf[PATH_MAX];
 	DIR *dir;
 	int fd;
 
lib/igt_sysfs.c +2 -2
index 15ed34be0088..9227e374bf44 100644
@@ -192,7 +192,7 @@ int igt_sysfs_open_parameters(int device)
 	if (params < 0) { /* builtin? */
 		drm_version_t version;
 		char name[32] = "";
-		char path[128];
+		char path[PATH_MAX];
 
 		memset(&version, 0, sizeof(version));
 		version.name_len = sizeof(name);
@@ -499,7 +499,7 @@ void kick_fbcon(bool enable)
 		return;
 
 	while ((de = readdir(dir))) {
-		char buf[128];
+		char buf[PATH_MAX];
 		int fd, len;
 
 		if (strncmp(de->d_name, "vtcon", 5))
tests/kms_hdmi_inject.c +1 -1
index cb916acec3c1..22570a4b637a 100644
@@ -170,7 +170,7 @@ eld_is_valid(void)
 			continue;
 
 		while ((snd_hda = readdir(dir))) {
-			char fpath[128];
+			char fpath[PATH_MAX];
 
 			if (*snd_hda->d_name == '.' ||
 			    strstr(snd_hda->d_name, "eld") == 0)
tests/pm_rpm.c +2 -2
index 47c9f1143484..9e8cf79b5128 100644
@@ -594,14 +594,14 @@ static int count_i2c_valid_edids(void)
 	DIR *dir;
 
 	struct dirent *dirent;
-	char full_name[32];
+	char full_name[PATH_MAX];
 
 	dir = opendir("/dev/");
 	igt_assert(dir);
 
 	while ((dirent = readdir(dir))) {
 		if (strncmp(dirent->d_name, "i2c-", 4) == 0) {
-			snprintf(full_name, 32, "/dev/%s", dirent->d_name);
+			sprintf(full_name, "/dev/%s", dirent->d_name);
 			fd = open(full_name, O_RDWR);
 			igt_assert_neq(fd, -1);
 			if (i2c_edid_is_valid(fd))
Signature · 6 lines
2.14.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw
Quoted 4 lines · Daniel Vetter
Quoted 3 lines · Eric Anholt

---

Quoted 8 lines
Quoted 2 lines

This little series cleans up many compiler warnings I saw when testing danvet's meson branch.

On the series: Reviewed-by: Daniel Vetter <[email protected]>

I've pulled in your other meson patches, they need minimal polish (e.g. my gcc doesn't have all the -W flags yours has, resulting in warnings about unknown flags without first checking for them).

Seems like you're on vacations already, so pulled them all in.

Thanks, Daniel

Quoted 98 lines

-Daniel

Quoted 92 lines
 lib/igt_debugfs.c       | 4 ++--
 lib/igt_sysfs.c         | 4 ++--
 tests/kms_hdmi_inject.c | 2 +-
 tests/pm_rpm.c          | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)
lib/igt_debugfs.c +2 -2
index 090b56e03555..63183e57229b 100644
@@ -491,7 +491,7 @@ static void igt_pipe_crc_reset(int drm_fd)
 	}
 
 	while ((dirent = readdir(dir))) {
-		char buf[128];
+		char buf[PATH_MAX];
 
 		if (strcmp(dirent->d_name, "crtc-") != 0)
 			continue;
@@ -525,7 +525,7 @@ static void igt_pipe_crc_reset(int drm_fd)
 static void pipe_crc_exit_handler(int sig)
 {
 	struct dirent *dirent;
-	char buf[128];
+	char buf[PATH_MAX];
 	DIR *dir;
 	int fd;
 
lib/igt_sysfs.c +2 -2
index 15ed34be0088..9227e374bf44 100644
@@ -192,7 +192,7 @@ int igt_sysfs_open_parameters(int device)
 	if (params < 0) { /* builtin? */
 		drm_version_t version;
 		char name[32] = "";
-		char path[128];
+		char path[PATH_MAX];
 
 		memset(&version, 0, sizeof(version));
 		version.name_len = sizeof(name);
@@ -499,7 +499,7 @@ void kick_fbcon(bool enable)
 		return;
 
 	while ((de = readdir(dir))) {
-		char buf[128];
+		char buf[PATH_MAX];
 		int fd, len;
 
 		if (strncmp(de->d_name, "vtcon", 5))
tests/kms_hdmi_inject.c +1 -1
index cb916acec3c1..22570a4b637a 100644
@@ -170,7 +170,7 @@ eld_is_valid(void)
 			continue;
 
 		while ((snd_hda = readdir(dir))) {
-			char fpath[128];
+			char fpath[PATH_MAX];
 
 			if (*snd_hda->d_name == '.' ||
 			    strstr(snd_hda->d_name, "eld") == 0)
tests/pm_rpm.c +2 -2
index 47c9f1143484..9e8cf79b5128 100644
@@ -594,14 +594,14 @@ static int count_i2c_valid_edids(void)
 	DIR *dir;
 
 	struct dirent *dirent;
-	char full_name[32];
+	char full_name[PATH_MAX];
 
 	dir = opendir("/dev/");
 	igt_assert(dir);
 
 	while ((dirent = readdir(dir))) {
 		if (strncmp(dirent->d_name, "i2c-", 4) == 0) {
-			snprintf(full_name, 32, "/dev/%s", dirent->d_name);
+			sprintf(full_name, "/dev/%s", dirent->d_name);
 			fd = open(full_name, O_RDWR);
 			igt_assert_neq(fd, -1);
 			if (i2c_edid_is_valid(fd))
Signature · 6 lines
2.14.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx