[PATCH 8/8] svsematest.c: Suppress warning

Cheng-Yang Chou
2025-07-12T13:42:50Z

src/svsematest/svsematest.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c
index f3cddf8..bdc82bc 100644
--- a/src/svsematest/svsematest.c
+++ b/src/svsematest/svsematest.c
@@ -84,6 +84,7 @@ void *semathread(void *param)
struct sched_param schedp;
struct sembuf sb = { 0, 0, 0};
sigset_t sigset;
+ int ret;

sigemptyset(&sigset);
pthread_sigmask(SIG_SETMASK, &sigset, NULL);
@@ -175,7 +176,10 @@ void *semathread(void *param)
int tracing_enabled =
open(tracing_enabled_file, O_WRONLY);
if (tracing_enabled >= 0) {
- write(tracing_enabled, "0", 1);
+ ret = write(tracing_enabled, "0", 1);
+ if (ret < 0)
+ fatal("Could not write to %s: %s\n",
+ tracing_enabled_file, strerror(errno));
close(tracing_enabled);
} else
fatal("Could not access %s\n",
@@ -544,7 +548,12 @@ int main(int argc, char *argv[])
fprintf(stderr, "Could not create shared memory\n");
return 1;
}
- ftruncate(shmem, totalsize);
+ if (ftruncate(shmem, totalsize) == -1) {
+ perror("ftruncate failed");
+ close(shmem);
+ shm_unlink("/sigwaittest");
+ return 1;
+ }
param = mmap(0, totalsize, PROT_READ|PROT_WRITE, MAP_SHARED,
shmem, 0);
if (param == MAP_FAILED) {
--
2.48.1