[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTin=0N0b=wK8974RGwXuTxpQ4BtH4bHwjsea+1tS@mail.gmail.com>
Date: Tue, 19 Oct 2010 14:33:01 +0300
From: Brian Gitonga Marete <marete@...hnix.com>
To: Ingo Molnar <mingo@...e.hu>
Cc: Frederic Weisbecker <fweisbec@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [PATCH] [PERF] (Userspace Tools) Fix a compilation error with
-fstack-protector and -Werror
On Tue, Oct 19, 2010 at 2:12 PM, Brian Gitonga Marete
<marete@...hnix.com> wrote:
> On Tue, Oct 19, 2010 at 9:40 AM, Ingo Molnar <mingo@...e.hu> wrote:
>>
>> * Brian Gitonga Marete <marete@...hnix.com> wrote:
>>
>>> On Tue, Oct 19, 2010 at 2:38 AM, Frederic Weisbecker <fweisbec@...il.com> wrote:
>>> > On Tue, Oct 19, 2010 at 02:24:00AM +0300, Brian Gitonga Marete wrote:
>>> >> The following patch fixes compilation of the perf user-space tools on,
>>> >> for example, gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) . It should not
>>> >> break anything else.
>>> >
>>> >
>>> >
>>> > Hi,
>>> >
>>> > What kind of warning have you encountered and why it fixes it?
>>> > Can you describe that in your changelog?
>>> >
>>>
>>> Hello Frederic,
>>>
>>> Some versions of gcc, e.g. gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4), have the
>>> (default) minimum size of buffers protected by `-fstack-protector' set to 8. But
>>> in perf, there exist much smaller automatic buffers.
>>
>> Hm, it's this code:
>>
>> /* newtWinChoice should really be accepting const char pointers... */
>> char yes[] = "Yes", no[] = "No";
>> return newtWinChoice(NULL, yes, no, (char *)msg) == 1;
>>
>> I.e. the code is messy and GCC is right to warn about it. Hence it would be somewhat
>> bad to actually remove the warning that pointed out some dodgy piece of code.
>>
>> Even if marking it const doesnt work due to the external libnewt API, we could at
>> least put 'yes' and 'no' into file scope and mark them static?
>
> OK. Now that I actually look closely at that fragment I can see its
> useless to create the automatic arrays. Local string literals would
> also work (i.e. just pass `"Yes"' and `"No"' to newtWinChoice). But
> can also do what you suggested if it is anticipated that they will be
> used somewhere else within the file at some other time -- Currently
> they are not.
>
Oops. Sorry. What I suggested won't work because of the
-Wwrite-strings default option. Which actually makes me understand why
the original author of the code made it the way it is. Your suggestion
of file-scope, static does solve the problem.
--
Brian Gitonga Marete
Toshnix Systems
Tel: +254722151590
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists