From owner-svn-src-head@FreeBSD.ORG Tue Jan 27 18:56:23 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C1157FA3; Tue, 27 Jan 2015 18:56:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AD7046CF; Tue, 27 Jan 2015 18:56:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0RIuNdq096246; Tue, 27 Jan 2015 18:56:23 GMT (envelope-from rrs@FreeBSD.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0RIuNT4096245; Tue, 27 Jan 2015 18:56:23 GMT (envelope-from rrs@FreeBSD.org) Message-Id: <201501271856.t0RIuNT4096245@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rrs set sender to rrs@FreeBSD.org using -f From: Randall Stewart Date: Tue, 27 Jan 2015 18:56:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r277800 - head/usr.sbin/pmcstudy X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2015 18:56:23 -0000 Author: rrs Date: Tue Jan 27 18:56:22 2015 New Revision: 277800 URL: https://svnweb.freebsd.org/changeset/base/277800 Log: Fix yet another coverty warning (missing io is NULL check) and in examining that warning I see yet another issue where we should be pclosing the io in the event of the error and its a command (not fclose only). Modified: head/usr.sbin/pmcstudy/pmcstudy.c Modified: head/usr.sbin/pmcstudy/pmcstudy.c ============================================================================== --- head/usr.sbin/pmcstudy/pmcstudy.c Tue Jan 27 18:27:07 2015 (r277799) +++ head/usr.sbin/pmcstudy/pmcstudy.c Tue Jan 27 18:56:22 2015 (r277800) @@ -1796,6 +1796,10 @@ process_file(char *filename) if (filename == NULL) { io = my_popen(command, "r", &pid_of_command); + if (io == NULL) { + printf("Can't popen the command %s\n", command); + return; + } } else { io = fopen(filename, "r"); if (io == NULL) { @@ -1808,8 +1812,10 @@ process_file(char *filename) if (cnts == NULL) { /* Nothing we can do */ printf("Nothing to do -- no counters built\n"); - if (io) { - fclose(io); + if (filename) { + fclose(io); + } else { + my_pclose(io, pid_of_command); } return; }