All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] copy.c: make copy_fd preserve meaningful errno
@ 2014-11-17 22:14 Stefan Beller
  2014-11-17 23:08 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 83+ messages in thread
From: Stefan Beller @ 2014-11-17 22:14 UTC (permalink / raw)
  To: gitster, git; +Cc: Ronnie Sahlberg, Jonathan Nieder, Stefan Beller

From: Ronnie Sahlberg <sahlberg@google.com>

Update copy_fd to return a meaningful errno on failure and also 
preserve the existing errno variable.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
As announced in [1], I'm going to take over the 
ref-transactions-reflog series by Ronnie Sahlberg.

This patch was sent previously to the list as part of
that series[2], but it seems to be unrelated to me.

Thanks,
Stefan

[1] http://www.mail-archive.com/git@vger.kernel.org/msg61051.html
[2] http://www.spinics.net/lists/git/msg240784.html
 copy.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/copy.c b/copy.c
index f2970ec..a8d366e 100644
--- a/copy.c
+++ b/copy.c
@@ -8,12 +8,17 @@ int copy_fd(int ifd, int ofd)
 		if (!len)
 			break;
 		if (len < 0) {
-			return error("copy-fd: read returned %s",
-				     strerror(errno));
+			int save_errno = errno;
+			error("copy-fd: read returned %s", strerror(errno));
+			errno = save_errno;
+			return -1;
+		}
+		if (write_in_full(ofd, buffer, len) < 0) {
+			int save_errno = errno;
+			error("copy-fd: write returned %s", strerror(errno));
+			errno = save_errno;
+			return -1;
 		}
-		if (write_in_full(ofd, buffer, len) < 0)
-			return error("copy-fd: write returned %s",
-				     strerror(errno));
 	}
 	return 0;
 }
-- 
2.2.0.rc1.24.g562add4

^ permalink raw reply related	[flat|nested] 83+ messages in thread

end of thread, other threads:[~2015-02-17 22:46 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-17 22:14 [PATCH] copy.c: make copy_fd preserve meaningful errno Stefan Beller
2014-11-17 23:08 ` Junio C Hamano
2014-11-17 23:13   ` Stefan Beller
2014-11-17 23:35 ` Jonathan Nieder
2014-11-18  0:18   ` Stefan Beller
2014-11-18  0:48     ` Jonathan Nieder
2014-11-18  1:01       ` Stefan Beller
2014-12-03  5:02         ` [PATCH 0/14] " Jonathan Nieder
2014-12-03  5:10           ` [PATCH 01/14] strbuf: introduce strbuf_prefixf() Jonathan Nieder
2014-12-03 20:10             ` Eric Sunshine
2014-12-03 20:14               ` Jonathan Nieder
2014-12-03 21:45             ` Junio C Hamano
2014-12-03 21:59               ` Jonathan Nieder
2014-12-03 22:09                 ` Jonathan Nieder
2014-12-03 22:40                 ` Junio C Hamano
2014-12-03  5:12           ` [PATCH 02/14] add_to_alternates_file: respect GIT_OBJECT_DIRECTORY Jonathan Nieder
2014-12-03 18:53             ` Junio C Hamano
2014-12-03  5:13           ` [PATCH 03/14] copy_fd: pass error message back through a strbuf Jonathan Nieder
2014-12-03 19:01             ` Junio C Hamano
2014-12-03 20:28               ` Jonathan Nieder
2014-12-03 21:00               ` Jeff King
2014-12-03 21:38                 ` Jonathan Nieder
2014-12-04  7:59                   ` Jeff King
2014-12-04  8:36                     ` Stefan Beller
2014-12-04  9:04                       ` Jeff King
2014-12-10 17:02                     ` Michael Haggerty
2014-12-10 19:00                       ` Junio C Hamano
2014-12-10 19:14                         ` Jeff King
2014-12-04  3:01               ` [PATCH/RFC] doc: document error handling functions and conventions (Re: [PATCH 03/14] copy_fd: pass error message back through a strbuf) Jonathan Nieder
2014-12-04 23:27                 ` Junio C Hamano
2014-12-04 23:37                   ` Jonathan Nieder
2014-12-04 23:41                   ` Jonathan Nieder
2014-12-04 23:44                     ` Jeff King
2014-12-04 23:52                       ` Junio C Hamano
2014-12-05  0:01                         ` Jeff King
2014-12-05 18:00                           ` Junio C Hamano
2014-12-07 10:07                             ` Jeff King
2014-12-09 18:43                               ` Junio C Hamano
2014-12-09 18:49                                 ` Jeff King
2015-02-12 23:08                                 ` Junio C Hamano
2015-02-17 15:50                                   ` Michael Haggerty
2015-02-17 16:03                                     ` Junio C Hamano
2015-02-17 16:05                                       ` Jeff King
2015-02-17 22:46                                         ` Junio C Hamano
2014-12-03 20:02             ` [PATCH 03/14] copy_fd: pass error message back through a strbuf Junio C Hamano
2014-12-03 20:18               ` Jonathan Nieder
2014-12-03 21:43                 ` Junio C Hamano
2014-12-03 21:51                   ` Jonathan Nieder
2014-12-03 20:20               ` Stefan Beller
2014-12-03  5:14           ` [PATCH 04/14] hold_lock_file_for_append: " Jonathan Nieder
2014-12-03  6:09             ` Torsten Bögershausen
2014-12-03  7:04               ` Jonathan Nieder
2014-12-03  5:16           ` [PATCH 05/14] lock_packed_refs: " Jonathan Nieder
2014-12-03  5:19           ` [PATCH 06/14] lockfile: introduce flag for locks outside .git Jonathan Nieder
2014-12-03 23:13             ` Junio C Hamano
2014-12-03 23:24               ` Jonathan Nieder
2014-12-03 23:25               ` Junio C Hamano
2014-12-03 23:29                 ` Jonathan Nieder
2014-12-03 23:38                   ` Junio C Hamano
2014-12-03 23:41                     ` Jonathan Nieder
2014-12-03 23:43                     ` Junio C Hamano
2014-12-03 23:57                   ` Jeff King
2014-12-04  5:51                   ` Junio C Hamano
2014-12-04 17:56                     ` Jonathan Nieder
2014-12-03  5:19           ` [PATCH 07/14] fast-import: use message from lockfile API when writing marks fails Jonathan Nieder
2014-12-03  5:20           ` [PATCH 08/14] credentials: use message from lockfile API when locking ~/.git-credentials fails Jonathan Nieder
2014-12-03  5:21           ` [PATCH 09/14] config: use message from lockfile API when locking config file fails Jonathan Nieder
2014-12-03 19:59             ` Junio C Hamano
2014-12-03 20:16               ` Jonathan Nieder
2014-12-03  5:22           ` [PATCH 10/14] rerere: error out on autoupdate failure Jonathan Nieder
2014-12-03  5:25           ` [PATCH 11/14] hold_locked_index: pass error message back through a strbuf Jonathan Nieder
2014-12-03  5:26           ` [PATCH 12/14] hold_lock_file_for_update: " Jonathan Nieder
2014-12-03 18:53             ` Jonathan Nieder
2014-12-03  5:26           ` [PATCH 13/14] lockfile: remove unused function 'unable_to_lock_die' Jonathan Nieder
2014-12-03  5:27           ` [PATCH 14/14] lockfile: make 'unable_to_lock_message' private Jonathan Nieder
2014-12-03 20:42             ` Stefan Beller
2014-11-18 16:32   ` [PATCH] copy.c: make copy_fd preserve meaningful errno Junio C Hamano
2014-11-18 17:08     ` Junio C Hamano
2014-11-21  9:14 ` Michael Haggerty
2014-11-21  9:17   ` Michael Haggerty
2014-11-21 17:48     ` Junio C Hamano
2014-11-21 17:54       ` Jeff King
2014-11-21 18:31         ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.