Skip to contentSkip to conversation

fs/eventpoll.c: fix compilation warning

PATCH Superseded Viresh Kumar 2 participants 5 messages Jan 14, 2011 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/eventpoll.c: fix compilation warning

This patch fixes following compilation warning
fs/eventpoll.c:1119: warning: 'slack' may be used uninitialized in this function

---
 fs/eventpoll.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/eventpoll.c +1 -1
index 8cf0724..c24a032 100644
@@ -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;
Signature · 1 line
1.7.2.2
#1 lore raw
Quoted 22 lines · Viresh Kumar

This patch fixes following compilation warning fs/eventpoll.c:1119: warning: 'slack' may be used uninitialized in this function

---
fs/eventpoll.c | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
fs/eventpoll.c +1 -1
index 8cf0724..c24a032 100644
@@ -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;
Quoted 1 line
	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

Signature · 1 line
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
#2 lore raw
Quoted 7 lines · Jack Stone
Quoted 5 lines
Quoted 5 lines
fs/eventpoll.c +1 -1
-	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.

Quoted 5 lines

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.

Signature · 1 line
viresh
#3 lore raw
Quoted 8 lines · viresh kumar
Quoted 7 lines · Jack Stone
Quoted 5 lines
Quoted 5 lines
fs/eventpoll.c +1 -1
-	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.

Quoted 8 lines
Quoted 5 lines

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

#4 lore raw

Review

Quoted 3 lines · Jack Stone

I meant something like

(quoted diff) +1 -1
-  long slack;
+  long uninitialized_var(slack);

Thanks Jack,

That's new to me!!
I will resend it with suggested changes.

Signature · 1 line
viresh