slirp fixes
cover slirp fixes
These patches replace http://patchwork.ozlabs.org/patch/181411/.
I modified the code as suggested by Jan Kiska and separated the original patch in two patches.
[PATCH 1/2] slirp: Remove wrong type casts ins debug statements [PATCH 2/2] slirp: Fix error reported by static code analysis
Regards,
Stefan W.
PATCH 1/2 slirp: Remove wrong type casts ins debug statements
The type casts of pointers to long are not allowed when sizeof(pointer) != sizeof(long).
--- slirp/tcp_subr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
slirp/tcp_subr.c +3 -3
@@ -114,9 +114,9 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,int win =0 ;DEBUG_CALL ("tcp_respond" ); -DEBUG_ARG ("tp = %lx" , (long )tp); -DEBUG_ARG ("ti = %lx" , (long )ti); -DEBUG_ARG ("m = %lx" , (long )m); +DEBUG_ARG ("tp = %p" , tp); +DEBUG_ARG ("ti = %p" , ti); +DEBUG_ARG ("m = %p" , m);DEBUG_ARG ("ack = %u" , ack);DEBUG_ARG ("seq = %u" , seq);DEBUG_ARG ("flags = %x" , flags);
Signature · 1 line
1.7.10
PATCH 2/2 slirp: Fix error reported by static code analysis
In reply to Stefan WeilReport from smatch:
slirp/tcp_subr.c:127 tcp_respond(17) error:
we previously assumed 'tp' could be null (see line 124)
Return if 'tp' is NULL.
--- slirp/tcp_subr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
slirp/tcp_subr.c +1 -1
@@ -124,7 +124,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,if (tp) win =sbspace (&tp->t_socket->so_rcv);if (m ==NULL ) { -if ((m =m_get (tp->t_socket->slirp)) ==NULL ) +if (!tp || (m =m_get (tp->t_socket->slirp)) ==NULL )return ; tlen =0 ; m->m_data +=IF_MAXLINKHDR ;
Signature · 1 line
1.7.10
Re: [Qemu-devel] [PATCH 2/2] slirp: Fix error reported by static code analysis
Quoted 18 lines · Stefan Weil
Report from smatch:
slirp/tcp_subr.c:127tcp_respond(17)error:
we previously assumed 'tp' could be null (see line 124)Return if 'tp' is NULL.
Signed-off-by Stefan Weil <[email protected]>--- slirp/tcp_subr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)slirp/tcp_subr.c +0
-0
slirp/tcp_subr.c tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m, · line 130
Quoted 8 lines
slirp/tcp_subr.c +1
-1@@ -124,7 +124,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,if (tp) win =sbspace (&tp->t_socket->so_rcv);if (m ==NULL ) { -if ((m =m_get (tp->t_socket->slirp)) ==NULL ) +if (!tp || (m =m_get (tp->t_socket->slirp)) ==NULL )return ; tlen =0 ; m->m_data +=IF_MAXLINKHDR ;
I suppose this is also stable material, therefore extending CC.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux
Jan Kiszka
AppliedQuoted 8 lines · Stefan Weil
These patches replace http://patchwork.ozlabs.org/patch/181411/.
I modified the code as suggested by Jan Kiska and separated the original patch in two patches.
[PATCH 1/2] slirp: Remove wrong type casts ins debug statements [PATCH 2/2] slirp: Fix error reported by static code analysis
Thanks, applied to slirp queue. And I'll propose patch 2 for stable as well.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux