From: Florian Bezdeka <florian.bezdeka@siemens.com>
To: jan.kiszka@siemens.com, xenomai@lists.linux.dev
Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>,
Florian Bezdeka <florian.bezdeka@siemens.com>
Subject: [PATCH v5] lib/psos/task.c: fix build with gcc >= 12 and -Ofast
Date: Fri, 15 Dec 2023 23:59:05 +0100 [thread overview]
Message-ID: <20231212-flo-fix-psos-tests-v5-1-60f2c0acbbae@siemens.com> (raw)
Fix the following build failure with gcc >= 12 and -Ofast (found by
buildroot autobuilders on xenomai 3.0.10 [1]):
task.c: In function 't_start':
task.c:398:16: error: 'ret' may be used uninitialized [-Werror=maybe-uninitialized]
398 | return ret;
| ^~~
task.c:364:13: note: 'ret' was declared here
364 | int ret;
| ^~~
task.c: In function 't_resume':
task.c:444:16: error: 'ret' may be used uninitialized [-Werror=maybe-uninitialized]
444 | return ret;
| ^~~
task.c:428:13: note: 'ret' was declared here
428 | int ret;
| ^~~
[1] http://autobuild.buildroot.org/results/bc1b40de22e563b704ad7f20b6bf4d1f73a6ed8a
CC: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
Changes in v5:
- Set err_r to ERR_OBJDEL in case threadobj_lock() failed in
get_psos_task()
- Link to v4: https://lore.kernel.org/r/20231212-flo-fix-psos-tests-v4-1-8c694902c07a@siemens.com
---
lib/psos/task.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/psos/task.c b/lib/psos/task.c
index f678be61d..b8b516dc9 100644
--- a/lib/psos/task.c
+++ b/lib/psos/task.c
@@ -62,8 +62,10 @@ static struct psos_task *find_psos_task(u_long tid, int *err_r)
magic = threadobj_get_magic(&task->thobj);
- if (magic == task_magic)
+ if (magic == task_magic) {
+ *err_r = SUCCESS;
return task;
+ }
if (magic == ~task_magic) {
*err_r = ERR_OBJDEL;
@@ -115,8 +117,10 @@ struct psos_task *get_psos_task(u_long tid, int *err_r)
* holding the lock. Therefore we need no cleanup handler
* here.
*/
- if (task == NULL || threadobj_lock(&task->thobj) == -EINVAL)
+ if (task == NULL || threadobj_lock(&task->thobj) == -EINVAL) {
+ *err_r = ERR_OBJDEL;
return NULL;
+ }
/* Check the magic word again, while we hold the lock. */
if (threadobj_get_magic(&task->thobj) != task_magic) {
@@ -141,6 +145,8 @@ struct psos_task *get_psos_task_or_self(u_long tid, int *err_r)
return NULL;
}
+ *err_r = SUCCESS;
+
/* This one might block but can't fail, it is ours. */
threadobj_lock(¤t->thobj);
@@ -447,8 +453,8 @@ out:
u_long t_setpri(u_long tid, u_long newprio, u_long *oldprio_r)
{
- int policy, ret = SUCCESS, cprio = 1;
struct sched_param_ex param_ex;
+ int policy, ret, cprio = 1;
struct psos_task *task;
struct service svc;
@@ -556,7 +562,7 @@ u_long t_getreg(u_long tid, u_long regnum, u_long *regvalue_r)
{
struct psos_task *task;
struct service svc;
- int ret = SUCCESS;
+ int ret;
if (regnum >= PSOSTASK_NR_REGS)
return ERR_REGNUM;
@@ -579,7 +585,7 @@ u_long t_setreg(u_long tid, u_long regnum, u_long regvalue)
{
struct psos_task *task;
struct service svc;
- int ret = SUCCESS;
+ int ret;
if (regnum >= PSOSTASK_NR_REGS)
return ERR_REGNUM;
@@ -601,9 +607,9 @@ out:
u_long t_mode(u_long mask, u_long newmask, u_long *oldmode_r)
{
struct sched_param_ex param_ex;
- int policy, ret = SUCCESS;
struct psos_task *task;
struct service svc;
+ int policy, ret;
CANCEL_DEFER(svc);
---
base-commit: ed69c34214f9fcf57b459e701ed4f65f6753bb8c
change-id: 20231212-flo-fix-psos-tests-d3ba4e7c27d4
Best regards,
--
Florian Bezdeka <florian.bezdeka@siemens.com>
next reply other threads:[~2023-12-15 22:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 22:59 Florian Bezdeka [this message]
2024-01-03 12:26 ` [PATCH v5] lib/psos/task.c: fix build with gcc >= 12 and -Ofast Jan Kiszka
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=20231212-flo-fix-psos-tests-v5-1-60f2c0acbbae@siemens.com \
--to=florian.bezdeka@siemens.com \
--cc=fontaine.fabrice@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=xenomai@lists.linux.dev \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).