Commit fb331185 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by David S. Miller

net: sctp: Move sequence start handling into sctp_transport_get_idx()

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: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 34ae6a1a
...@@ -310,7 +310,7 @@ static struct sctp_transport *sctp_transport_get_next(struct seq_file *seq) ...@@ -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, static struct sctp_transport *sctp_transport_get_idx(struct seq_file *seq,
loff_t pos) loff_t pos)
{ {
void *obj; void *obj = SEQ_START_TOKEN;
while (pos && (obj = sctp_transport_get_next(seq)) && !IS_ERR(obj)) while (pos && (obj = sctp_transport_get_next(seq)) && !IS_ERR(obj))
pos--; pos--;
...@@ -347,7 +347,7 @@ static void *sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos) ...@@ -347,7 +347,7 @@ static void *sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos)
if (err) if (err)
return ERR_PTR(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) 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) ...@@ -462,7 +462,7 @@ static void *sctp_remaddr_seq_start(struct seq_file *seq, loff_t *pos)
if (err) if (err)
return ERR_PTR(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) static void *sctp_remaddr_seq_next(struct seq_file *seq, void *v, loff_t *pos)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment