xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
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 v5] lib/psos/task.c: fix build with gcc >= 12 and -Ofast
Date: Wed, 3 Jan 2024 13:26:48 +0100	[thread overview]
Message-ID: <ee263824-c81e-4713-9597-c8fccac64b1f@siemens.com> (raw)
In-Reply-To: <20231212-flo-fix-psos-tests-v5-1-60f2c0acbbae@siemens.com>

On 15.12.23 23:59, 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>
> ---
> 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(&current->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,

Thanks, applied.
Jan

-- 
Siemens AG, Technology
Linux Expert Center


      reply	other threads:[~2024-01-03 12:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15 22:59 [PATCH v5] lib/psos/task.c: fix build with gcc >= 12 and -Ofast Florian Bezdeka
2024-01-03 12:26 ` 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=ee263824-c81e-4713-9597-c8fccac64b1f@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).