diff mbox

[06/27] power: wakeup: Remove use of seq_printf return value

Message ID 1b5eb664ab9313f1c5b9868819e1960d5dc597ac.1424573328.git.joe@perches.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Joe Perches Feb. 22, 2015, 2:53 a.m. UTC
The seq_printf return value, because it's frequently misused,
will eventually be converted to void.

See: commit 1f33c41c03da ("seq_file: Rename seq_overflow() to
     seq_has_overflowed() and make public")

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/base/power/wakeup.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

Comments

Pavel Machek Feb. 22, 2015, 9:38 p.m. UTC | #1
On Sat 2015-02-21 18:53:33, Joe Perches wrote:
> The seq_printf return value, because it's frequently misused,
> will eventually be converted to void.
> 
> See: commit 1f33c41c03da ("seq_file: Rename seq_overflow() to
>      seq_has_overflowed() and make public")

You've just removed overflow handling from
print_wakeup_source_stats. Can you explain why that is good idea?

								Pavel

> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -842,7 +842,6 @@ static int print_wakeup_source_stats(struct seq_file *m,
>  	unsigned long active_count;
>  	ktime_t active_time;
>  	ktime_t prevent_sleep_time;
> -	int ret;
>  
>  	spin_lock_irqsave(&ws->lock, flags);
>  
> @@ -865,17 +864,16 @@ static int print_wakeup_source_stats(struct seq_file *m,
>  		active_time = ktime_set(0, 0);
>  	}
>  
> -	ret = seq_printf(m, "%-12s\t%lu\t\t%lu\t\t%lu\t\t%lu\t\t"
> -			"%lld\t\t%lld\t\t%lld\t\t%lld\t\t%lld\n",
> -			ws->name, active_count, ws->event_count,
> -			ws->wakeup_count, ws->expire_count,
> -			ktime_to_ms(active_time), ktime_to_ms(total_time),
> -			ktime_to_ms(max_time), ktime_to_ms(ws->last_time),
> -			ktime_to_ms(prevent_sleep_time));
> +	seq_printf(m, "%-12s\t%lu\t\t%lu\t\t%lu\t\t%lu\t\t%lld\t\t%lld\t\t%lld\t\t%lld\t\t%lld\n",
> +		   ws->name, active_count, ws->event_count,
> +		   ws->wakeup_count, ws->expire_count,
> +		   ktime_to_ms(active_time), ktime_to_ms(total_time),
> +		   ktime_to_ms(max_time), ktime_to_ms(ws->last_time),
> +		   ktime_to_ms(prevent_sleep_time));
>  
>  	spin_unlock_irqrestore(&ws->lock, flags);
>  
> -	return ret;
> +	return 0;
Joe Perches Feb. 22, 2015, 9:52 p.m. UTC | #2
On Sun, 2015-02-22 at 22:38 +0100, Pavel Machek wrote:
> On Sat 2015-02-21 18:53:33, Joe Perches wrote:
> > The seq_printf return value, because it's frequently misused,
> > will eventually be converted to void. 
> > 
> > See: commit 1f33c41c03da ("seq_file: Rename seq_overflow() to
> >      seq_has_overflowed() and make public")
> 
> You've just removed overflow handling from
> print_wakeup_source_stats.
> 
>  Can you explain why that is good idea?

If overflow occurs, the seq_file subsystem allocates
a bigger buffer and calls the show function again.

See Al's comment in the 0/n patch and here:
https://lkml.org/lkml/2015/2/17/642


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pavel Machek Feb. 23, 2015, 11:54 a.m. UTC | #3
On Sun 2015-02-22 13:52:58, Joe Perches wrote:
> On Sun, 2015-02-22 at 22:38 +0100, Pavel Machek wrote:
> > On Sat 2015-02-21 18:53:33, Joe Perches wrote:
> > > The seq_printf return value, because it's frequently misused,
> > > will eventually be converted to void. 
> > > 
> > > See: commit 1f33c41c03da ("seq_file: Rename seq_overflow() to
> > >      seq_has_overflowed() and make public")
> > 
> > You've just removed overflow handling from
> > print_wakeup_source_stats.
> > 
> >  Can you explain why that is good idea?
> 
> If overflow occurs, the seq_file subsystem allocates
> a bigger buffer and calls the show function again.
> 
> See Al's comment in the 0/n patch and here:
> https://lkml.org/lkml/2015/2/17/642

You may want to explain while this is good idea in the changelog.

From your explanation it looks like error is somehow handled
on higher-level retry, but...
diff mbox

Patch

diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index c2744b3..23fe220 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -842,7 +842,6 @@  static int print_wakeup_source_stats(struct seq_file *m,
 	unsigned long active_count;
 	ktime_t active_time;
 	ktime_t prevent_sleep_time;
-	int ret;
 
 	spin_lock_irqsave(&ws->lock, flags);
 
@@ -865,17 +864,16 @@  static int print_wakeup_source_stats(struct seq_file *m,
 		active_time = ktime_set(0, 0);
 	}
 
-	ret = seq_printf(m, "%-12s\t%lu\t\t%lu\t\t%lu\t\t%lu\t\t"
-			"%lld\t\t%lld\t\t%lld\t\t%lld\t\t%lld\n",
-			ws->name, active_count, ws->event_count,
-			ws->wakeup_count, ws->expire_count,
-			ktime_to_ms(active_time), ktime_to_ms(total_time),
-			ktime_to_ms(max_time), ktime_to_ms(ws->last_time),
-			ktime_to_ms(prevent_sleep_time));
+	seq_printf(m, "%-12s\t%lu\t\t%lu\t\t%lu\t\t%lu\t\t%lld\t\t%lld\t\t%lld\t\t%lld\t\t%lld\n",
+		   ws->name, active_count, ws->event_count,
+		   ws->wakeup_count, ws->expire_count,
+		   ktime_to_ms(active_time), ktime_to_ms(total_time),
+		   ktime_to_ms(max_time), ktime_to_ms(ws->last_time),
+		   ktime_to_ms(prevent_sleep_time));
 
 	spin_unlock_irqrestore(&ws->lock, flags);
 
-	return ret;
+	return 0;
 }
 
 /**