From patchwork Wed Nov 17 22:12:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 71625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E65BFB7161 for ; Thu, 18 Nov 2010 09:12:39 +1100 (EST) Received: (qmail 11644 invoked by alias); 17 Nov 2010 22:12:37 -0000 Received: (qmail 11626 invoked by uid 22791); 17 Nov 2010 22:12:35 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, SARE_SUB_PCT_LETTER, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 17 Nov 2010 22:12:29 +0000 Received: from kpbe20.cbf.corp.google.com (kpbe20.cbf.corp.google.com [172.25.105.84]) by smtp-out.google.com with ESMTP id oAHMCQbv011940 for ; Wed, 17 Nov 2010 14:12:27 -0800 Received: from gwb1 (gwb1.prod.google.com [10.200.2.1]) by kpbe20.cbf.corp.google.com with ESMTP id oAHMCOrc021869 for ; Wed, 17 Nov 2010 14:12:25 -0800 Received: by gwb1 with SMTP id 1so1992157gwb.40 for ; Wed, 17 Nov 2010 14:12:24 -0800 (PST) Received: by 10.150.195.6 with SMTP id s6mr15081657ybf.261.1290031944492; Wed, 17 Nov 2010 14:12:24 -0800 (PST) Received: from coign.google.com (dhcp-172-22-124-218.mtv.corp.google.com [172.22.124.218]) by mx.google.com with ESMTPS id q4sm1038307yba.14.2010.11.17.14.12.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 17 Nov 2010 14:12:23 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: [gccgo] Use %m instead of strerror Date: Wed, 17 Nov 2010 14:12:21 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch changes gccgo to use %m instead of calling strerror. Committed to gccgo branch. Ian diff -r 0cd7f1dff9ad go/go.cc --- a/go/go.cc Wed Nov 17 13:53:29 2010 -0800 +++ b/go/go.cc Wed Nov 17 14:10:36 2010 -0800 @@ -73,7 +73,7 @@ { file = fopen(filename, "r"); if (file == NULL) - fatal_error("cannot open %s: %s", filename, strerror(errno)); + fatal_error("cannot open %s: %m", filename); } Lex lexer(filename, file); diff -r 0cd7f1dff9ad go/import-archive.cc --- a/go/import-archive.cc Wed Nov 17 13:53:29 2010 -0800 +++ b/go/import-archive.cc Wed Nov 17 14:10:36 2010 -0800 @@ -147,8 +147,7 @@ struct stat st; if (fstat(this->fd_, &st) < 0) { - error_at(this->location_, "%s: %s", this->filename_.c_str(), - strerror(errno)); + error_at(this->location_, "%s: %m", this->filename_.c_str()); return false; } this->filesize_ = st.st_size; @@ -157,8 +156,7 @@ if (::lseek(this->fd_, 0, SEEK_SET) < 0 || ::read(this->fd_, buf, sizeof(armagt)) != sizeof(armagt)) { - error_at(this->location_, "%s: %s", this->filename_.c_str(), - strerror(errno)); + error_at(this->location_, "%s: %m", this->filename_.c_str()); return false; } this->is_thin_archive_ = memcmp(buf, armagt, sizeof(armagt)) == 0; @@ -208,8 +206,7 @@ if (::lseek(this->fd_, offset, SEEK_SET) < 0 || ::read(this->fd_, buf, size) != size) { - error_at(this->location_, "%s: %s", this->filename_.c_str(), - strerror(errno)); + error_at(this->location_, "%s: %m", this->filename_.c_str()); return false; } return true; @@ -225,16 +222,14 @@ Archive_header hdr; if (::lseek(this->fd_, off, SEEK_SET) < 0) { - error_at(this->location_, "%s: %s", this->filename_.c_str(), - strerror(errno)); + error_at(this->location_, "%s: %m", this->filename_.c_str()); return false; } ssize_t got = ::read(this->fd_, &hdr, sizeof hdr); if (got != sizeof hdr) { if (got < 0) - error_at(this->location_, "%s: %s", this->filename_.c_str(), - strerror(errno)); + error_at(this->location_, "%s: %m", this->filename_.c_str()); else if (got > 0) error_at(this->location_, "%s: short archive header at %ld", this->filename_.c_str(), static_cast(off)); @@ -406,7 +401,7 @@ *memfd = open(filename.c_str(), O_RDONLY); if (*memfd < 0) { - error_at(this->location_, "%s: %s", filename.c_str(), strerror(errno)); + error_at(this->location_, "%s: %m", filename.c_str()); return false; } *memoff = 0; diff -r 0cd7f1dff9ad go/import.cc --- a/go/import.cc Wed Nov 17 13:53:29 2010 -0800 +++ b/go/import.cc Wed Nov 17 14:10:36 2010 -0800 @@ -104,7 +104,7 @@ if (fd < 0) { if (errno != ENOENT && errno != EISDIR) - warning_at(location, 0, "%s: %s", filename.c_str(), strerror(errno)); + warning_at(location, 0, "%s: %m", filename.c_str()); fd = Import::try_suffixes(&found_filename); if (fd < 0) @@ -184,8 +184,7 @@ if (lseek(fd, 0, SEEK_SET) < 0) { - error_at(location, "lseek %s failed: %s", filename.c_str(), - strerror(errno)); + error_at(location, "lseek %s failed: %m", filename.c_str()); return NULL; } @@ -233,8 +232,7 @@ if (lseek(fd, offset + sec_offset, SEEK_SET) < 0) { - error_at(location, "lseek %s failed: %s", filename.c_str(), - strerror(errno)); + error_at(location, "lseek %s failed: %m", filename.c_str()); return NULL; } @@ -242,8 +240,7 @@ ssize_t c = read(fd, buf, sec_length); if (c < 0) { - error_at(location, "read %s failed: %s", filename.c_str(), - strerror(errno)); + error_at(location, "read %s failed: %m", filename.c_str()); return NULL; } if (c < sec_length) @@ -821,7 +818,7 @@ { if (lseek(fd, 0, SEEK_SET) != 0) { - error("lseek failed: %s", strerror(errno)); + error("lseek failed: %m"); this->set_saw_error(); } } @@ -849,7 +846,7 @@ if (got < 0) { if (!this->saw_error()) - error("read failed: %s", strerror(errno)); + error("read failed: %m"); this->set_saw_error(); return false; } @@ -857,7 +854,7 @@ if (lseek(this->fd_, - got, SEEK_CUR) != 0) { if (!this->saw_error()) - error("lseek failed: %s", strerror(errno)); + error("lseek failed: %m"); this->set_saw_error(); return false; } @@ -879,7 +876,7 @@ if (lseek(this->fd_, skip, SEEK_CUR) != 0) { if (!this->saw_error()) - error("lseek failed: %s", strerror(errno)); + error("lseek failed: %m"); this->set_saw_error(); } if (!this->data_.empty())