Bug 1003929: Remove some useless declarations in netwerk/sctp found by scan-build, the LLVM/Clang static analyzer. r=mcmanus
authorSylvestre Ledru <sledru@mozilla.com>
Tue, 13 May 2014 17:01:15 +0200 (2014-05-13)
changeset 354922 ab117d946959657bdb3270e253de2e1e3dc74cac
parent 354921 e73f4eaf842307787278cc03aff867d447e7a6b2
child 354923 95a3115a8c35557b032921b7d25981c5f01a7df1
push id29
push usergszorc@mozilla.com
push dateFri, 02 Dec 2016 20:39:54 +0000 (2016-12-02)
converted fromf5a20d7f35fb2148d7ba6cd98e845db7c8678516
reviewersmcmanus
bugs1003929
milestone32.0a1
Bug 1003929: Remove some useless declarations in netwerk/sctp found by scan-build, the LLVM/Clang static analyzer. r=mcmanus
netwerk/sctp/datachannel/DataChannel.cpp
netwerk/sctp/src/netinet/sctp_pcb.c
netwerk/sctp/src/netinet/sctp_sha1.c
netwerk/sctp/src/user_socket.c
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -710,17 +710,19 @@ DataChannelConnection::SctpDtlsOutput(vo
   // SCTP has an option for Apple, on IP connections only, to release at least
   // one of the locks before calling a packet output routine; with changes to
   // the underlying SCTP stack this might remove the need to use an async proxy.
   if (0 /*peer->IsSTSThread()*/) {
     res = peer->SendPacket(static_cast<unsigned char *>(buffer), length, false);
   } else {
     unsigned char *data = new unsigned char[length];
     memcpy(data, buffer, length);
-    res = -1;
+    // Commented out since we have to Dispatch SendPacket to avoid deadlock"
+    // res = -1;
+
     // XXX It might be worthwhile to add an assertion against the thread
     // somehow getting into the DataChannel/SCTP code again, as
     // DISPATCH_SYNC is not fully blocking.  This may be tricky, as it
     // needs to be a per-thread check, not a global.
     peer->mSTS->Dispatch(WrapRunnable(
                            nsRefPtr<DataChannelConnection>(peer),
                            &DataChannelConnection::SendPacket, data, length, true),
                          NS_DISPATCH_NORMAL);
--- a/netwerk/sctp/src/netinet/sctp_pcb.c
+++ b/netwerk/sctp/src/netinet/sctp_pcb.c
@@ -3166,17 +3166,16 @@ sctp_inpcb_bind(struct socket *so, struc
 #ifdef SCTP_MVRF
 	int i;
 #endif
 	uint16_t lport;
 	int error;
 	uint32_t vrf_id;
 
 	lport = 0;
-	error = 0;
 	bindall = 1;
 	inp = (struct sctp_inpcb *)so->so_pcb;
 #if defined(INET) || (defined(INET6) && defined(__APPLE__)) || defined(__FreeBSD__) || defined(__APPLE__)
 	ip_inp = (struct inpcb *)so->so_pcb;
 #endif
 #ifdef SCTP_DEBUG
 	if (addr) {
 		SCTPDBG(SCTP_DEBUG_PCB1, "Bind called port: %d\n",
--- a/netwerk/sctp/src/netinet/sctp_sha1.c
+++ b/netwerk/sctp/src/netinet/sctp_sha1.c
@@ -201,17 +201,16 @@ sctp_sha1_update(struct sctp_sha1_contex
 	while (number_left > 0) {
 		left_to_fill = sizeof(ctx->sha_block) - ctx->how_many_in_block;
 		if (left_to_fill > number_left) {
 			/* can only partially fill up this one */
 			memcpy(&ctx->sha_block[ctx->how_many_in_block],
 			    ptr, number_left);
 			ctx->how_many_in_block += number_left;
 			ctx->running_total += number_left;
-			number_left = 0;
 			break;
 		} else {
 			/* block is now full, process it */
 			memcpy(&ctx->sha_block[ctx->how_many_in_block],
 			    ptr, left_to_fill);
 			sctp_sha1_process_a_block(ctx,
 			    (unsigned int *)ctx->sha_block);
 			number_left -= left_to_fill;
--- a/netwerk/sctp/src/user_socket.c
+++ b/netwerk/sctp/src/user_socket.c
@@ -2777,17 +2777,16 @@ sctp_userspace_ip_output(int *result, st
 	WSABUF winbuf;
 #else
 	struct iovec send_iovec[MAXLEN_MBUF_CHAIN];
 	struct msghdr msg_hdr;
 #endif
 	int use_udp_tunneling;
 
 	*result = 0;
-	send_count = 0;
 
 	m = SCTP_HEADER_TO_CHAIN(o_pak);
 	m_orig = m;
 
 	len = sizeof(struct ip);
 	if (SCTP_BUF_LEN(m) < len) {
 		if ((m = m_pullup(m, len)) == 0) {
 			SCTP_PRINTF("Can not get the IP header in the first mbuf.\n");
@@ -2933,17 +2932,16 @@ void sctp_userspace_ip6_output(int *resu
 	WSABUF winbuf;
 #else
 	struct iovec send_iovec[MAXLEN_MBUF_CHAIN];
 	struct msghdr msg_hdr;
 #endif
 	int use_udp_tunneling;
 
 	*result = 0;
-	send_count = 0;
 
 	m = SCTP_HEADER_TO_CHAIN(o_pak);
 	m_orig = m;
 
 	len = sizeof(struct ip6_hdr);
 
 	if (SCTP_BUF_LEN(m) < len) {
 		if ((m = m_pullup(m, len)) == 0) {