* [PATCH] fs/eventpoll.c: fix compilation warning
@ 2011-01-14 7:15 Viresh Kumar
2011-01-14 9:33 ` Jack Stone
0 siblings, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2011-01-14 7:15 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel; +Cc: Viresh Kumar
This patch fixes following compilation warning
fs/eventpoll.c:1119: warning: 'slack' may be used uninitialized in this function
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
fs/eventpoll.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 8cf0724..c24a032 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1116,7 +1116,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
{
int res, eavail, timed_out = 0;
unsigned long flags;
- long slack;
+ long slack = 0;
wait_queue_t wait;
struct timespec end_time;
ktime_t expires, *to = NULL;
--
1.7.2.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] fs/eventpoll.c: fix compilation warning
2011-01-14 7:15 [PATCH] fs/eventpoll.c: fix compilation warning Viresh Kumar
@ 2011-01-14 9:33 ` Jack Stone
2011-01-14 9:38 ` viresh kumar
0 siblings, 1 reply; 5+ messages in thread
From: Jack Stone @ 2011-01-14 9:33 UTC (permalink / raw)
To: Viresh Kumar, linux-kernel, linux-fsdevel
Viresh Kumar" <viresh.kumar@st.com> wrote:
>This patch fixes following compilation warning
>fs/eventpoll.c:1119: warning: 'slack' may be used uninitialized in this
>function
>
>Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
>---
> fs/eventpoll.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>diff --git a/fs/eventpoll.c b/fs/eventpoll.c
>index 8cf0724..c24a032 100644
>--- a/fs/eventpoll.c
>+++ b/fs/eventpoll.c
>@@ -1116,7 +1116,7 @@ static int ep_poll(struct eventpoll *ep, struct
>epoll_event __user *events,
> {
> int res, eavail, timed_out = 0;
> unsigned long flags;
>- long slack;
>+ long slack = 0;
> wait_queue_t wait;
> struct timespec end_time;
> ktime_t expires, *to = NULL;
I don't think this is the correct fix. This function is fine unless timeout is negative.
If a negative timeout is possible then this function will create timer far in the future. I'll leave it up to the maintainer how to solve that one. The two solutions I can see are making timeout unsigned or extending the bottom case of the if to <=0.
Either way we should use uninitalized_var() rather than setting it to zero.
Hope this makes sense,
Jack
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs/eventpoll.c: fix compilation warning
2011-01-14 9:33 ` Jack Stone
@ 2011-01-14 9:38 ` viresh kumar
2011-01-14 10:55 ` Jack Stone
0 siblings, 1 reply; 5+ messages in thread
From: viresh kumar @ 2011-01-14 9:38 UTC (permalink / raw)
To: Jack Stone; +Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
On 01/14/2011 03:03 PM, Jack Stone wrote:
>> >- long slack;
>> >+ long slack = 0;
>> > wait_queue_t wait;
>> > struct timespec end_time;
>> > ktime_t expires, *to = NULL;
> I don't think this is the correct fix. This function is fine unless timeout is negative.
>
> If a negative timeout is possible then this function will create timer far in the future.
>I'll leave it up to the maintainer how to solve that one. The two solutions I can see are making
>timeout unsigned or extending the bottom case of the if to <=0.
>
> Either way we should use uninitalized_var() rather than setting it to zero.
Using uninitialized var gives compilation warning, How should we fix that.
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs/eventpoll.c: fix compilation warning
2011-01-14 9:38 ` viresh kumar
@ 2011-01-14 10:55 ` Jack Stone
2011-01-14 11:12 ` viresh kumar
0 siblings, 1 reply; 5+ messages in thread
From: Jack Stone @ 2011-01-14 10:55 UTC (permalink / raw)
To: viresh kumar; +Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
On 14/01/2011 09:38, viresh kumar wrote:
> On 01/14/2011 03:03 PM, Jack Stone wrote:
>>>> - long slack;
>>>> + long slack = 0;
>>>> wait_queue_t wait;
>>>> struct timespec end_time;
>>>> ktime_t expires, *to = NULL;
>> I don't think this is the correct fix. This function is fine unless timeout is negative.
>>
>> If a negative timeout is possible then this function will create timer far in the future.
>> I'll leave it up to the maintainer how to solve that one. The two solutions I can see are making
>> timeout unsigned or extending the bottom case of the if to <=0.
>>
>> Either way we should use uninitalized_var() rather than setting it to zero.
>
> Using uninitialized var gives compilation warning, How should we fix that.
>
I meant something like
- long slack;
+ long uninitialized_var(slack);
I just had a go at generating this warning and couldn't. I've tried GCC
4.4.5 (From Fedora 13) and latest sparse.
Thanks,
Jack
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs/eventpoll.c: fix compilation warning
2011-01-14 10:55 ` Jack Stone
@ 2011-01-14 11:12 ` viresh kumar
0 siblings, 0 replies; 5+ messages in thread
From: viresh kumar @ 2011-01-14 11:12 UTC (permalink / raw)
To: Jack Stone; +Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
On 01/14/2011 04:25 PM, Jack Stone wrote:
> I meant something like
> - long slack;
> + long uninitialized_var(slack);
Thanks Jack,
That's new to me!!
I will resend it with suggested changes.
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-14 11:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-14 7:15 [PATCH] fs/eventpoll.c: fix compilation warning Viresh Kumar
2011-01-14 9:33 ` Jack Stone
2011-01-14 9:38 ` viresh kumar
2011-01-14 10:55 ` Jack Stone
2011-01-14 11:12 ` viresh kumar
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 NNTP newsgroup(s).