[PATCH i-g-t 1/3] Use PATH_MAX to fix some sprintf-into-short-buffers warnings.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Eric Anholt <eric@xxxxxxxxxx>
---

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(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 090b56e03555..63183e57229b 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -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;
 
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 15ed34be0088..9227e374bf44 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -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))
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
index cb916acec3c1..22570a4b637a 100644
--- a/tests/kms_hdmi_inject.c
+++ b/tests/kms_hdmi_inject.c
@@ -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)
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index 47c9f1143484..9e8cf79b5128 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -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))
-- 
2.14.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux