From owner-svn-src-all@FreeBSD.ORG Tue Jun 10 12:59:57 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 29FB0B35; Tue, 10 Jun 2014 12:59:57 +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 F1ADE230A; Tue, 10 Jun 2014 12:59:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5ACxu8x091019; Tue, 10 Jun 2014 12:59:56 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5ACxu72091018; Tue, 10 Jun 2014 12:59:56 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201406101259.s5ACxu72091018@svn.freebsd.org> From: Ed Maste Date: Tue, 10 Jun 2014 12:59:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267324 - head/tools/tools/vt/fontcvt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 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: Tue, 10 Jun 2014 12:59:57 -0000 Author: emaste Date: Tue Jun 10 12:59:56 2014 New Revision: 267324 URL: http://svnweb.freebsd.org/changeset/base/267324 Log: vt fontcvt: handle failure writing output font Modified: head/tools/tools/vt/fontcvt/fontcvt.c Modified: head/tools/tools/vt/fontcvt/fontcvt.c ============================================================================== --- head/tools/tools/vt/fontcvt/fontcvt.c Tue Jun 10 09:36:10 2014 (r267323) +++ head/tools/tools/vt/fontcvt/fontcvt.c Tue Jun 10 12:59:56 2014 (r267324) @@ -354,7 +354,7 @@ number_glyphs(void) gl->g_index = idx++; } -static void +static int write_glyphs(FILE *fp) { struct glyph *gl; @@ -362,8 +362,10 @@ write_glyphs(FILE *fp) for (i = 0; i < VFNT_MAPS; i++) { TAILQ_FOREACH(gl, &glyphs[i], g_list) - fwrite(gl->g_data, wbytes * height, 1, fp); + if (fwrite(gl->g_data, wbytes * height, 1, fp) != 1) + return (1); } + return (0); } static void @@ -390,7 +392,7 @@ struct file_mapping { uint16_t length; } __packed; -static void +static int write_mappings(FILE *fp, unsigned int map_idx) { struct mapping_list *ml = &maps[map_idx]; @@ -405,10 +407,12 @@ write_mappings(FILE *fp, unsigned int ma fm.source = htobe32(mp->m_char); fm.destination = htobe16(mp->m_glyph->g_index); fm.length = htobe16(mp->m_length - 1); - fwrite(&fm, sizeof fm, 1, fp); + if (fwrite(&fm, sizeof fm, 1, fp) != 1) + return (1); } } assert(i == j); + return (0); } struct file_header { @@ -441,13 +445,19 @@ write_fnt(const char *filename) fh.map_count[1] = htobe32(map_folded_count[1]); fh.map_count[2] = htobe32(map_folded_count[2]); fh.map_count[3] = htobe32(map_folded_count[3]); - fwrite(&fh, sizeof fh, 1, fp); + if (fwrite(&fh, sizeof fh, 1, fp) != 1) { + perror(filename); + return (1); + } - write_glyphs(fp); - write_mappings(fp, VFNT_MAP_NORMAL); - write_mappings(fp, 1); - write_mappings(fp, VFNT_MAP_BOLD); - write_mappings(fp, 3); + if (write_glyphs(fp) != 0 || + write_mappings(fp, VFNT_MAP_NORMAL) != 0 || + write_mappings(fp, 1) != 0 || + write_mappings(fp, VFNT_MAP_BOLD) != 0 || + write_mappings(fp, 3) != 0) { + perror(filename); + return (1); + } return (0); }