From owner-svn-soc-all@freebsd.org Mon Nov 30 21:25:10 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C6021A3DD32 for ; Mon, 30 Nov 2015 21:25:10 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (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 B7420160A for ; Mon, 30 Nov 2015 21:25:10 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id tAULPAFY060150 for ; Mon, 30 Nov 2015 21:25:10 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id tAULPA3T060060 for svn-soc-all@FreeBSD.org; Mon, 30 Nov 2015 21:25:10 GMT (envelope-from def@FreeBSD.org) Date: Mon, 30 Nov 2015 21:25:10 GMT Message-Id: <201511302125.tAULPA3T060060@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r294583 - soc2013/def/crashdump-head/sbin/savecore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Nov 2015 21:25:10 -0000 Author: def Date: Mon Nov 30 21:25:09 2015 New Revision: 294583 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=294583 Log: Log error message. Simplify code. Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/savecore.c Mon Nov 30 21:23:00 2015 (r294582) +++ soc2013/def/crashdump-head/sbin/savecore/savecore.c Mon Nov 30 21:25:09 2015 (r294583) @@ -191,12 +191,13 @@ fd = open(keyname, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd == -1) { - syslog(LOG_ERR, "Unable to open %s to write the key.", keyname); + syslog(LOG_ERR, "Unable to open %s to write the key: %m.", + keyname); return (false); } if (write(fd, dumpkey, dumpkeysize) != (ssize_t)dumpkeysize) { - syslog(LOG_ERR, "Unable to write the key to %s.", keyname); + syslog(LOG_ERR, "Unable to write the key to %s: %m.", keyname); close(fd); return (false); } @@ -705,8 +706,9 @@ xo_finish_h(xoinfo); fclose(info); - isencrypted = false; - if (dumpkeysize > 0) { + if (dumpkeysize == 0) { + isencrypted = false; + } else { isencrypted = true; dumpkey = calloc(1, dumpkeysize); if (dumpkey == NULL) { @@ -715,9 +717,8 @@ goto closeall; } - error = read(fd, dumpkey, dumpkeysize); - if (error != (int)dumpkeysize) { - syslog(LOG_ERR, "Unable to read kernel dump key."); + if (read(fd, dumpkey, dumpkeysize) != (ssize_t)dumpkeysize) { + syslog(LOG_ERR, "Unable to read kernel dump key: %m."); nerr++; goto closeall; }