From: Jan Kiszka <jan.kiszka@siemens.com>
To: Florian Bezdeka <florian.bezdeka@siemens.com>, xenomai@lists.linux.dev
Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Subject: Re: [PATCH v4] lib/psos/task.c: fix build with gcc >= 12 and -Ofast
Date: Thu, 14 Dec 2023 07:54:10 +0100 [thread overview]
Message-ID: <404e70cf-d338-423c-87a8-1b02cb3797c7@siemens.com> (raw)
In-Reply-To: <20231212-flo-fix-psos-tests-v4-1-8c694902c07a@siemens.com>
On 12.12.23 16:43, Florian Bezdeka wrote:
> 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>
> ---
> Difference to v3:
> - Removed caller initializations of err_r
> - find_psos_task() will initialize err_r in any case
And what if threadobj_lock() fails in get_psos_task?
Jan
> ---
> lib/psos/task.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/lib/psos/task.c b/lib/psos/task.c
> index f678be61d..6d075c19d 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;
> @@ -141,6 +143,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 +451,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 +560,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 +583,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 +605,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,
--
Siemens AG, Technology
Linux Expert Center
prev parent reply other threads:[~2023-12-14 6:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 15:43 [PATCH v4] lib/psos/task.c: fix build with gcc >= 12 and -Ofast Florian Bezdeka
2023-12-14 6:54 ` Jan Kiszka [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=404e70cf-d338-423c-87a8-1b02cb3797c7@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=florian.bezdeka@siemens.com \
--cc=fontaine.fabrice@gmail.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).