From: Samuel Holland <samuel@sholland.org>
To: musl@lists.openwall.com
Cc: Samuel Holland <samuel@sholland.org>
Subject: [PATCH 1/2] resolve -Wrestrict warnings
Date: Sat, 29 Jun 2019 16:22:43 -0500 [thread overview]
Message-ID: <20190629212244.42963-2-samuel@sholland.org> (raw)
In-Reply-To: <20190629212244.42963-1-samuel@sholland.org>
The old/new parameters to pthread_sigmask, sigprocmask, and setitimer
are marked __restrict, so passing the same address to both is
prohibited. Modify callers of these functions to use a separate object
for each argument.
---
src/aio/lio_listio.c | 6 +++---
src/signal/sigset.c | 8 ++++----
src/unistd/ualarm.c | 6 +++---
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/aio/lio_listio.c b/src/aio/lio_listio.c
index 7b6a03d3..0799c15d 100644
--- a/src/aio/lio_listio.c
+++ b/src/aio/lio_listio.c
@@ -113,7 +113,7 @@ int lio_listio(int mode, struct aiocb *restrict const *restrict cbs, int cnt, st
if (st) {
pthread_attr_t a;
- sigset_t set;
+ sigset_t set, set_old;
pthread_t td;
if (sev->sigev_notify == SIGEV_THREAD) {
@@ -128,13 +128,13 @@ int lio_listio(int mode, struct aiocb *restrict const *restrict cbs, int cnt, st
}
pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
sigfillset(&set);
- pthread_sigmask(SIG_BLOCK, &set, &set);
+ pthread_sigmask(SIG_BLOCK, &set, &set_old);
if (pthread_create(&td, &a, wait_thread, st)) {
free(st);
errno = EAGAIN;
return -1;
}
- pthread_sigmask(SIG_SETMASK, &set, 0);
+ pthread_sigmask(SIG_SETMASK, &set_old, 0);
}
return 0;
diff --git a/src/signal/sigset.c b/src/signal/sigset.c
index 0d7b4564..f3e8c407 100644
--- a/src/signal/sigset.c
+++ b/src/signal/sigset.c
@@ -3,7 +3,7 @@
void (*sigset(int sig, void (*handler)(int)))(int)
{
struct sigaction sa, sa_old;
- sigset_t mask;
+ sigset_t mask, mask_old;
sigemptyset(&mask);
if (sigaddset(&mask, sig) < 0)
@@ -12,7 +12,7 @@ void (*sigset(int sig, void (*handler)(int)))(int)
if (handler == SIG_HOLD) {
if (sigaction(sig, 0, &sa_old) < 0)
return SIG_ERR;
- if (sigprocmask(SIG_BLOCK, &mask, &mask) < 0)
+ if (sigprocmask(SIG_BLOCK, &mask, &mask_old) < 0)
return SIG_ERR;
} else {
sa.sa_handler = handler;
@@ -20,8 +20,8 @@ void (*sigset(int sig, void (*handler)(int)))(int)
sigemptyset(&sa.sa_mask);
if (sigaction(sig, &sa, &sa_old) < 0)
return SIG_ERR;
- if (sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0)
+ if (sigprocmask(SIG_UNBLOCK, &mask, &mask_old) < 0)
return SIG_ERR;
}
- return sigismember(&mask, sig) ? SIG_HOLD : sa_old.sa_handler;
+ return sigismember(&mask_old, sig) ? SIG_HOLD : sa_old.sa_handler;
}
diff --git a/src/unistd/ualarm.c b/src/unistd/ualarm.c
index 855504bc..2985855c 100644
--- a/src/unistd/ualarm.c
+++ b/src/unistd/ualarm.c
@@ -7,7 +7,7 @@ unsigned ualarm(unsigned value, unsigned interval)
struct itimerval it = {
.it_interval.tv_usec = interval,
.it_value.tv_usec = value
- };
- setitimer(ITIMER_REAL, &it, &it);
- return it.it_value.tv_sec*1000000 + it.it_value.tv_usec;
+ }, it_old;
+ setitimer(ITIMER_REAL, &it, &it_old);
+ return it_old.it_value.tv_sec*1000000 + it_old.it_value.tv_usec;
}
--
2.21.0
next prev parent reply other threads:[~2019-06-29 21:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-29 21:22 [PATCH 0/2] Resolve compiler warnings in master Samuel Holland
2019-06-29 21:22 ` Samuel Holland [this message]
2019-06-29 21:22 ` [PATCH 2/2] use the correct attributes for ___errno_location Samuel Holland
2019-06-29 21:49 ` Rich Felker
2019-06-29 21:46 ` [PATCH 0/2] Resolve compiler warnings in master Rich Felker
2019-06-29 23:05 ` Samuel Holland
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=20190629212244.42963-2-samuel@sholland.org \
--to=samuel@sholland.org \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).