From: "Alex Xu (Hello71)" <alex_y_xu@yahoo.ca>
To: musl@lists.openwall.com
Subject: [musl] [v2] fix various warnings/theoretical UB
Date: Wed, 01 Nov 2023 19:44:00 -0400 [thread overview]
Message-ID: <1698882125.xwrfx4lpgy.none@localhost> (raw)
In-Reply-To: <1688401586.hkqjuyrd3s.none@localhost>
[-- Attachment #1: Type: text/plain, Size: 156 bytes --]
See attached patches. Changes from previous version:
1. drop patches 3 and 4 (not UB)
2. rename "tmp" to "dummy"
3. adjust commit messages
Thanks!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-timer_create-volatile-static-static-volatile.patch --]
[-- Type: text/x-patch; name=0001-timer_create-volatile-static-static-volatile.patch, Size: 923 bytes --]
From 5b7b756c1fbedc823319ec474cf56a22d978b8f4 Mon Sep 17 00:00:00 2001
From: "Alex Xu (Hello71)" <alex_y_xu@yahoo.ca>
Date: Wed, 1 Nov 2023 19:37:08 -0400
Subject: [PATCH 1/2] timer_create: volatile static -> static volatile
C11 6.11.5p1:
> The placement of a storage-class specifier other than at the
> beginning of the declaration specifiers in a declaration is an
> obsolescent feature.
gcc also warns about this.
---
src/time/timer_create.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/time/timer_create.c b/src/time/timer_create.c
index cd32c945..9216b3ab 100644
--- a/src/time/timer_create.c
+++ b/src/time/timer_create.c
@@ -61,7 +61,7 @@ static void *start(void *arg)
int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict res)
{
- volatile static int init = 0;
+ static volatile int init = 0;
pthread_t td;
pthread_attr_t attr;
int r;
--
2.42.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-__year_to_secs-fix-dangling-pointer.patch --]
[-- Type: text/x-patch; name=0002-__year_to_secs-fix-dangling-pointer.patch, Size: 937 bytes --]
From beee5f00e0f19fa46166f7afbd92f108c25002fd Mon Sep 17 00:00:00 2001
From: "Alex Xu (Hello71)" <alex_y_xu@yahoo.ca>
Date: Wed, 1 Nov 2023 19:37:44 -0400
Subject: [PATCH 2/2] __year_to_secs: fix dangling pointer
The lifetime of the compound literal ends after the "if" statement's
implicit block. gcc also warns about this.
---
src/time/__year_to_secs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/time/__year_to_secs.c b/src/time/__year_to_secs.c
index 2824ec6d..b42f5a6d 100644
--- a/src/time/__year_to_secs.c
+++ b/src/time/__year_to_secs.c
@@ -10,9 +10,9 @@ long long __year_to_secs(long long year, int *is_leap)
return 31536000*(y-70) + 86400*leaps;
}
- int cycles, centuries, leaps, rem;
+ int cycles, centuries, leaps, rem, dummy;
- if (!is_leap) is_leap = &(int){0};
+ if (!is_leap) is_leap = &dummy;
cycles = (year-100) / 400;
rem = (year-100) % 400;
if (rem < 0) {
--
2.42.0
prev parent reply other threads:[~2023-11-01 23:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1688401586.hkqjuyrd3s.none.ref@localhost>
2023-07-03 17:55 ` [musl] " Alex Xu (Hello71)
2023-07-03 19:59 ` Rich Felker
2023-07-03 21:23 ` Jens Gustedt
2023-07-03 22:57 ` Rich Felker
2023-07-03 22:30 ` Alex Xu (Hello71)
2023-11-01 23:44 ` Alex Xu (Hello71) [this message]
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=1698882125.xwrfx4lpgy.none@localhost \
--to=alex_y_xu@yahoo.ca \
--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).