From owner-svn-src-all@FreeBSD.ORG Sun Jun 27 14:21:08 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB1C71065670; Sun, 27 Jun 2010 14:21:08 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A99B88FC12; Sun, 27 Jun 2010 14:21:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o5REL8gj009593; Sun, 27 Jun 2010 14:21:08 GMT (envelope-from gavin@svn.freebsd.org) Received: (from gavin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5REL8ld009591; Sun, 27 Jun 2010 14:21:08 GMT (envelope-from gavin@svn.freebsd.org) Message-Id: <201006271421.o5REL8ld009591@svn.freebsd.org> From: Gavin Atkinson Date: Sun, 27 Jun 2010 14:21:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r209551 - head/usr.bin/tftp X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jun 2010 14:21:08 -0000 Author: gavin Date: Sun Jun 27 14:21:08 2010 New Revision: 209551 URL: http://svn.freebsd.org/changeset/base/209551 Log: Fix transfer statistics in the "send file" case - The conditional used to print the stats were using an uninitialised variable. [1] Fix trasnfer statistics in the "receive file" case - the statistics struct was being cleared both before and after the initial connect to the remote server. As a result, the printed time and calculated bandwidth covers the time to connect ad well as the time to transfer the file. This may not be ideal, but now at least matches the "send file" case. Found by: clang static analyser [1] Reviewed by: imp Modified: head/usr.bin/tftp/tftp.c Modified: head/usr.bin/tftp/tftp.c ============================================================================== --- head/usr.bin/tftp/tftp.c Sun Jun 27 14:11:03 2010 (r209550) +++ head/usr.bin/tftp/tftp.c Sun Jun 27 14:21:08 2010 (r209551) @@ -75,7 +75,6 @@ xmitfile(int peer, char *port, int fd, c struct tftphdr *rp; int n, i; uint16_t block; - uint32_t amount; struct sockaddr_storage serv; /* valid server port number */ char recvbuffer[MAXPKTSIZE]; struct tftp_stats tftp_stats; @@ -162,7 +161,7 @@ xmitfile(int peer, char *port, int fd, c tftp_send(peer, &block, &tftp_stats); read_close(); - if (amount > 0) + if (tftp_stats.amount > 0) printstats("Sent", verbose, &tftp_stats); txrx_error = 1; @@ -243,8 +242,6 @@ recvfile(int peer, char *port, int fd, c return; } - stats_init(&tftp_stats); - /* * If the first packet is an OACK packet instead of an DATA packet, * handle it different.