From: Philippe Gerum <rpm@xenomai.org>
To: Thomas De Schampheleire <patrickdepinguin+xenomai@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] [PATCH 4 of 4] psos: fix compiler warning: cprio could be used uninitialized
Date: Wed, 26 Oct 2011 13:58:57 +0200 [thread overview]
Message-ID: <4EA7F601.9000101@domain.hid> (raw)
In-Reply-To: <CAAXf6LWaVORRe5g6x2vgKRuZ7XG0N8V643XxBJFTgHQZfwt7-A@mail.gmail.com>
On 10/26/2011 01:04 PM, Thomas De Schampheleire wrote:
> On Wed, Oct 26, 2011 at 12:25 PM, Philippe Gerum<rpm@xenomai.org> wrote:
>> On 10/19/2011 09:35 AM, Thomas De Schampheleire wrote:
>>>
>>> Assign default 1 to satisfy compiler (tested with gcc 4.4.3)
>>>
>>> Signed-off-by: Thomas De Schampheleire<thomas.de.schampheleire@domain.hid>
>>> Signed-off-by: Ronny Meeus<ronny.meeus@domain.hid>
>>>
>>> ---
>>> lib/psos/task.c | 4 ++--
>>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/lib/psos/task.c b/lib/psos/task.c
>>> --- a/lib/psos/task.c
>>> +++ b/lib/psos/task.c
>>> @@ -247,7 +247,7 @@ u_long t_create(const char *name, u_long
>>> pthread_attr_t thattr;
>>> struct syncstate syns;
>>> struct service svc;
>>> - int ret, cprio;
>>> + int ret, cprio = 1;
>>> char short_name[5];
>>>
>>> ret = check_task_priority(prio,&cprio);
>>> @@ -414,7 +414,7 @@ u_long t_resume(u_long tid)
>>> u_long t_setpri(u_long tid, u_long newprio, u_long *oldprio_r)
>>> {
>>> struct psos_task *task;
>>> - int ret, cprio;
>>> + int ret, cprio = 1;
>>>
>>> task = get_psos_task_or_self(tid,&ret);
>>> if (task == NULL)
>>>
>>
>> Looks like 4.4.3 is wrong, 4.4.4+ does it better and does not choke. Just to
>> make sure the optimizer is given a chance to see the truth, could you try
>> without this patch, but with tagging check_task_priority() as inline
>> instead, with --disable-debug, then with --enable-debug=full switches?
>
> Without this patch, inlined check_task_prio, --disable-debug:
> /bin/sh ../../libtool --tag=CC --mode=compile
> /repo/tdescham/reborn/buildroot-forge/output/host/usr/bin/powerpc-linux-gcc
> -DHAVE_CONFIG_H -I. -I../../lib/include -O2 -D_GNU_SOURCE
> -D_REENTRANT -Wall -pipe -Wstrict-prototypes -Wmissing-prototypes
> -Wno-long-long -Wno-unused-parameter -Werror -D__XENO__ -D__IN_XENO__
> -Wstrict-prototypes -I../../include -pipe -Os -D_LARGEFILE_SOURCE
> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -MT libpsos_la-task.lo
> -MD -MP -MF .deps/libpsos_la-task.Tpo -c -o libpsos_la-task.lo `test
> -f 'task.c' || echo './'`task.c
> libtool: compile:
> /repo/tdescham/reborn/buildroot-forge/output/host/usr/bin/powerpc-linux-gcc
> -DHAVE_CONFIG_H -I. -I../../lib/include -O2 -D_GNU_SOURCE -D_REENTRANT
> -Wall -pipe -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long
> -Wno-unused-parameter -Werror -D__XENO__ -D__IN_XENO__
> -Wstrict-prototypes -I../../include -pipe -Os -D_LARGEFILE_SOURCE
> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -MT libpsos_la-task.lo
> -MD -MP -MF .deps/libpsos_la-task.Tpo -c task.c -fPIC -DPIC -o
> .libs/libpsos_la-task.o
> cc1: warnings being treated as errors
> task.c: In function 't_setpri':
> task.c:417: error: 'cprio' may be used uninitialized in this function
> make[3]: *** [libpsos_la-task.lo] Error 1
>
> Without this patch, inlined check_task_prio, --enable-debug=full
> /bin/sh ../../libtool --tag=CC --mode=compile
> /repo/tdescham/reborn/buildroot-forge/output/host/usr/bin/powerpc-linux-gcc
> -DHAVE_CONFIG_H -I. -I../../lib/include -g -D__XENO_DEBUG__
> -D__XENO_DEBUG_FULL__ -D_GNU_SOURCE -D_REENTRANT -Wall -pipe
> -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long
> -Wno-unused-parameter -Werror -D__XENO__ -D__IN_XENO__
> -Wstrict-prototypes -I../../include -pipe -Os -D_LARGEFILE_SOURCE
> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -MT libpsos_la-task.lo
> -MD -MP -MF .deps/libpsos_la-task.Tpo -c -o libpsos_la-task.lo `test
> -f 'task.c' || echo './'`task.c
> libtool: compile:
> /repo/tdescham/reborn/buildroot-forge/output/host/usr/bin/powerpc-linux-gcc
> -DHAVE_CONFIG_H -I. -I../../lib/include -g -D__XENO_DEBUG__
> -D__XENO_DEBUG_FULL__ -D_GNU_SOURCE -D_REENTRANT -Wall -pipe
> -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long
> -Wno-unused-parameter -Werror -D__XENO__ -D__IN_XENO__
> -Wstrict-prototypes -I../../include -pipe -Os -D_LARGEFILE_SOURCE
> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -MT libpsos_la-task.lo
> -MD -MP -MF .deps/libpsos_la-task.Tpo -c task.c -fPIC -DPIC -o
> .libs/libpsos_la-task.o
> cc1: warnings being treated as errors
> task.c: In function 't_setpri':
> task.c:417: error: 'cprio' may be used uninitialized in this function
> make[3]: *** [libpsos_la-task.lo] Error 1
>
>
> So, debug or not, compiler keeps complaining.
> For your reference, this is the change I did instead of the patch:
> diff --git a/lib/psos/task.c b/lib/psos/task.c
> --- a/lib/psos/task.c
> +++ b/lib/psos/task.c
> @@ -228,7 +228,7 @@ int psos_task_normalize_priority(unsigne
> return psos_prio;
> }
>
> -static int check_task_priority(u_long psos_prio, int *core_prio)
> +static inline int check_task_priority(u_long psos_prio, int *core_prio)
> {
> if (psos_prio< 1 || psos_prio> 255) /* In theory. */
> return ERR_PRIOR;
>
>
> powerpc-linux-gcc (crosstool-NG 1.12.1 - buildroot 2011.08-hgc55c56f04355) 4.4.3
> Copyright (C) 2010 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> ~Thomas
>
Ok, so I'll merge this.
--
Philippe.
next prev parent reply other threads:[~2011-10-26 11:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-19 7:35 [Xenomai-help] [PATCH 0 of 4] xenomai-forge PSOS: miscellaneous fixes Thomas De Schampheleire
2011-10-19 7:35 ` [Xenomai-help] [PATCH 1 of 4] psos.h: add definition of ERR_OBJTFULL Thomas De Schampheleire
2011-10-26 10:19 ` Philippe Gerum
2011-10-26 10:26 ` Thomas De Schampheleire
2011-10-26 10:33 ` Philippe Gerum
2011-10-26 11:11 ` Thomas De Schampheleire
2011-10-26 12:01 ` Philippe Gerum
2011-10-19 7:35 ` [Xenomai-help] [PATCH 2 of 4] psos: port long_names feature to xenomai-forge Thomas De Schampheleire
2011-10-26 10:21 ` Philippe Gerum
2011-10-26 10:41 ` Thomas De Schampheleire
2011-10-26 11:57 ` Philippe Gerum
2011-10-19 7:35 ` [Xenomai-help] [PATCH 3 of 4] psos: add tm_getm function Thomas De Schampheleire
2011-10-26 10:22 ` Philippe Gerum
2011-10-26 10:42 ` Thomas De Schampheleire
2011-10-19 7:35 ` [Xenomai-help] [PATCH 4 of 4] psos: fix compiler warning: cprio could be used uninitialized Thomas De Schampheleire
2011-10-26 10:25 ` Philippe Gerum
2011-10-26 11:04 ` Thomas De Schampheleire
2011-10-26 11:58 ` Philippe Gerum [this message]
2011-10-26 12:32 ` Thomas De Schampheleire
2011-10-26 9:44 ` [Xenomai-help] [PATCH 0 of 4] xenomai-forge PSOS: miscellaneous fixes Thomas De Schampheleire
2011-10-26 12:47 ` Philippe Gerum
2011-10-26 12:54 ` Thomas De Schampheleire
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=4EA7F601.9000101@domain.hid \
--to=rpm@xenomai.org \
--cc=patrickdepinguin+xenomai@domain.hid \
--cc=xenomai@xenomai.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.