]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (test_mkfds) save errno before calling system calls for clean-up
authorMasatake YAMATO <yamato@redhat.com>
Fri, 27 Sep 2024 16:39:52 +0000 (01:39 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Fri, 27 Sep 2024 16:39:52 +0000 (01:39 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/helpers/test_mkfds.c

index 5b009bb6f4c23e2bf36ed1ffa09685e38f4e6939..38c39292ccf006c5ccea5dabc071fcbe052133f6 100644 (file)
@@ -2519,7 +2519,9 @@ static void *make_mqueue(const struct factory *factory, struct fdesc fdescs[],
 
        fd = mq_open(mqueue_data->path, O_CREAT|O_EXCL | O_RDONLY, S_IRUSR | S_IWUSR, &attr);
        if (fd < 0) {
+               int e = errno;
                mqueue_data_free(mqueue_data);
+               errno = e;
                err(EXIT_FAILURE, "failed in mq_open(3) for reading");
        }
 
@@ -2599,8 +2601,10 @@ static void *make_mqueue(const struct factory *factory, struct fdesc fdescs[],
 
                /* Wait till the child is ready. */
                if (mq_receive(fdescs[0].fd, &c, 1, NULL) < 0) {
+                       int e = errno;
                        mq_close(fdescs[0].fd);
                        mqueue_data_free(mqueue_data);
+                       errno = e;
                        err(EXIT_FAILURE,
                            "failed in mq_receive() the readiness notification from the child");
                }