netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: sctp: Move sequence start handling into sctp_transport_get_idx()
@ 2016-01-15 13:44 Geert Uytterhoeven
  2016-01-15 19:05 ` Marcelo Ricardo Leitner
  2016-01-15 20:12 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2016-01-15 13:44 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, David S. Miller, Xin Long
  Cc: linux-sctp, netdev, linux-kernel, Geert Uytterhoeven

net/sctp/proc.c: In function ‘sctp_transport_get_idx’:
net/sctp/proc.c:313: warning: ‘obj’ may be used uninitialized in this function

This is currently a false positive, as all callers check for a zero
offset first, and handle this case in the exact same way.

Move the check and handling into sctp_transport_get_idx() to kill the
compiler warning, and avoid future bugs.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Compile-tested only.
---
 net/sctp/proc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index dfa7eeccb5373053..684c5b31563badc1 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -310,7 +310,7 @@ static struct sctp_transport *sctp_transport_get_next(struct seq_file *seq)
 static struct sctp_transport *sctp_transport_get_idx(struct seq_file *seq,
 						     loff_t pos)
 {
-	void *obj;
+	void *obj = SEQ_START_TOKEN;
 
 	while (pos && (obj = sctp_transport_get_next(seq)) && !IS_ERR(obj))
 		pos--;
@@ -347,7 +347,7 @@ static void *sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos)
 	if (err)
 		return ERR_PTR(err);
 
-	return *pos ? sctp_transport_get_idx(seq, *pos) : SEQ_START_TOKEN;
+	return sctp_transport_get_idx(seq, *pos);
 }
 
 static void sctp_assocs_seq_stop(struct seq_file *seq, void *v)
@@ -462,7 +462,7 @@ static void *sctp_remaddr_seq_start(struct seq_file *seq, loff_t *pos)
 	if (err)
 		return ERR_PTR(err);
 
-	return *pos ? sctp_transport_get_idx(seq, *pos) : SEQ_START_TOKEN;
+	return sctp_transport_get_idx(seq, *pos);
 }
 
 static void *sctp_remaddr_seq_next(struct seq_file *seq, void *v, loff_t *pos)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: sctp: Move sequence start handling into sctp_transport_get_idx()
  2016-01-15 13:44 [PATCH] net: sctp: Move sequence start handling into sctp_transport_get_idx() Geert Uytterhoeven
@ 2016-01-15 19:05 ` Marcelo Ricardo Leitner
  2016-01-15 20:12 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Ricardo Leitner @ 2016-01-15 19:05 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Vlad Yasevich, Neil Horman, David S. Miller, Xin Long, linux-sctp,
	netdev, linux-kernel

On Fri, Jan 15, 2016 at 02:44:31PM +0100, Geert Uytterhoeven wrote:
> net/sctp/proc.c: In function ‘sctp_transport_get_idx’:
> net/sctp/proc.c:313: warning: ‘obj’ may be used uninitialized in this function
> 
> This is currently a false positive, as all callers check for a zero
> offset first, and handle this case in the exact same way.
> 
> Move the check and handling into sctp_transport_get_idx() to kill the
> compiler warning, and avoid future bugs.
> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Compile-tested only.

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: sctp: Move sequence start handling into sctp_transport_get_idx()
  2016-01-15 13:44 [PATCH] net: sctp: Move sequence start handling into sctp_transport_get_idx() Geert Uytterhoeven
  2016-01-15 19:05 ` Marcelo Ricardo Leitner
@ 2016-01-15 20:12 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-01-15 20:12 UTC (permalink / raw)
  To: geert; +Cc: vyasevich, nhorman, lucien.xin, linux-sctp, netdev, linux-kernel

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Fri, 15 Jan 2016 14:44:31 +0100

> net/sctp/proc.c: In function ‘sctp_transport_get_idx’:
> net/sctp/proc.c:313: warning: ‘obj’ may be used uninitialized in this function
> 
> This is currently a false positive, as all callers check for a zero
> offset first, and handle this case in the exact same way.
> 
> Move the check and handling into sctp_transport_get_idx() to kill the
> compiler warning, and avoid future bugs.
> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

Applied, thanks Geert.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-15 20:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-15 13:44 [PATCH] net: sctp: Move sequence start handling into sctp_transport_get_idx() Geert Uytterhoeven
2016-01-15 19:05 ` Marcelo Ricardo Leitner
2016-01-15 20:12 ` David Miller

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).