public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Cheng-Yang Chou <yphbchou0911@gmail.com>
To: williams@redhat.com, jkacur@redhat.com
Cc: linux-rt-users@vger.kernel.org, jserv@ccns.ncku.edu.tw,
	yphbchou0911@gmail.com
Subject: [PATCH 6/8] deadline_test.c: Suppress warning
Date: Sat, 12 Jul 2025 21:42:11 +0800	[thread overview]
Message-ID: <20250712134213.58582-7-yphbchou0911@gmail.com> (raw)
In-Reply-To: <20250712134213.58582-1-yphbchou0911@gmail.com>

Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
 src/sched_deadline/deadline_test.c | 37 ++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
index ca2da47..4f9a6a6 100644
--- a/src/sched_deadline/deadline_test.c
+++ b/src/sched_deadline/deadline_test.c
@@ -325,6 +325,7 @@ static void ftrace_write(char *buf, const char *fmt, ...)
 {
 	va_list ap;
 	int n;
+	int ret;
 
 	if (mark_fd < 0)
 		return;
@@ -333,7 +334,9 @@ static void ftrace_write(char *buf, const char *fmt, ...)
 	n = my_vsprintf(buf, BUFSIZ, fmt, ap);
 	va_end(ap);
 
-	write(mark_fd, buf, n);
+	ret = write(mark_fd, buf, n);
+	if (ret < 0)
+		perror("ftrace write failed");
 }
 
 /**
@@ -626,6 +629,10 @@ static int mount_cpuset(void)
 	if (fd < 0)
 		return fd;
 	ret = write(fd, "0", 2);
+	if (ret < 0) {
+		close(fd);
+		return ret;
+	}
 	close(fd);
 
 	return 0;
@@ -875,7 +882,19 @@ static void destroy_cpuset(const char *name, int print)
 		sprintf(buf, "%d", pid);
 		if (print)
 			printf("Moving %d out of %s\n", pid, name);
-		write(fd, buf, strlen(buf));
+		ret = write(fd, buf, strlen(buf));
+		if(ret<0 && errno == ENOSPC) {
+			/*
+			 * If we get ENOSPC, then we have a problem, as it
+			 * means that the cpuset is full, and we cannot move
+			 * the tasks out of it.
+			 */
+			fclose(fp);
+			close(fd);
+			fprintf(stderr, "Failed to move %d out of %s\n", pid, name);
+			perror("write");
+			return;
+		}
 	}
 	fclose(fp);
 	close(fd);
@@ -910,16 +929,21 @@ static void destroy_cpuset(const char *name, int print)
 static void teardown(void)
 {
 	int fd;
+	int ret;
 
 	fd = open_cpuset(CPUSET_PATH, "cpuset.cpu_exclusive");
 	if (fd >= 0) {
-		write(fd, "0", 2);
+		ret = write(fd, "0", 2);
+		if (ret < 0)
+			perror("cpuset.cpu_exclusive");
 		close(fd);
 	}
 
 	fd = open_cpuset(CPUSET_PATH, "cpuset.sched_load_balance");
 	if (fd >= 0) {
-		write(fd, "1", 2);
+		ret = write(fd, "1", 2);
+		if (ret < 0)
+			perror("cpuset.sched_load_balance");
 		close(fd);
 	}
 
@@ -1790,6 +1814,7 @@ int main(int argc, char **argv)
 	int rt_task = 0;
 	int i;
 	int c;
+	int ret;
 
 	cpu_count = sysconf(_SC_NPROCESSORS_CONF);
 	if (cpu_count < 1) {
@@ -2041,7 +2066,9 @@ int main(int argc, char **argv)
 			exit(-1);
 		}
 
-		system("cat /sys/fs/cgroup/cpuset/my_cpuset/tasks");
+		ret = system("cat /sys/fs/cgroup/cpuset/my_cpuset/tasks");
+		if (ret < 0)
+			perror("system call failed");
 	}
 
 	pthread_barrier_wait(&barrier);
-- 
2.48.1


  parent reply	other threads:[~2025-07-12 13:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-12 13:42 [PATCH 0/8] Fix -Wunused-result warnings by checking return values Cheng-Yang Chou
2025-07-12 13:42 ` [PATCH 1/8] rt-utils.c: Suppress warning Cheng-Yang Chou
2025-07-25 18:04   ` John Kacur
2025-07-12 13:42 ` [PATCH 2/8] pmqtest.c: " Cheng-Yang Chou
2025-07-25 18:07   ` John Kacur
2025-07-12 13:42 ` [PATCH 3/8] ptsematest.c: " Cheng-Yang Chou
2025-07-25 18:09   ` John Kacur
2025-07-12 13:42 ` [PATCH 4/8] rt-migrate-test.c: " Cheng-Yang Chou
2025-07-25 18:10   ` John Kacur
2025-07-12 13:42 ` [PATCH 5/8] cyclicdeadline.c: " Cheng-Yang Chou
2025-07-12 13:42 ` Cheng-Yang Chou [this message]
2025-07-12 13:42 ` [PATCH 7/8] sigwaittest.c: " Cheng-Yang Chou
2025-07-12 13:42 ` [PATCH 8/8] svsematest.c: " Cheng-Yang Chou
2025-07-25 18:16 ` [PATCH 0/8] Fix -Wunused-result warnings by checking return values John Kacur
2025-07-25 18:20   ` Cheng-Yang Chou

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=20250712134213.58582-7-yphbchou0911@gmail.com \
    --to=yphbchou0911@gmail.com \
    --cc=jkacur@redhat.com \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.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