Skip to content
This repository was archived by the owner on Jul 2, 2019. It is now read-only.

Commit 7b4e2b7

Browse files
committed
Merge branch 'ef/mingw-write'
* ef/mingw-write: mingw: remove mingw_write prefer xwrite instead of write
2 parents de20e44 + c9df6f4 commit 7b4e2b7

File tree

5 files changed

+4
-25
lines changed

5 files changed

+4
-25
lines changed

builtin/merge.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead
367367
sha1_to_hex(commit->object.sha1));
368368
pretty_print_commit(&ctx, commit, &out);
369369
}
370-
if (write(fd, out.buf, out.len) < 0)
370+
if (write_in_full(fd, out.buf, out.len) != out.len)
371371
die_errno(_("Writing SQUASH_MSG"));
372372
if (close(fd))
373373
die_errno(_("Finishing SQUASH_MSG"));

compat/mingw.c

-17
Original file line numberDiff line numberDiff line change
@@ -304,23 +304,6 @@ int mingw_open (const char *filename, int oflags, ...)
304304
return fd;
305305
}
306306

307-
#undef write
308-
ssize_t mingw_write(int fd, const void *buf, size_t count)
309-
{
310-
/*
311-
* While write() calls to a file on a local disk are translated
312-
* into WriteFile() calls with a maximum size of 64KB on Windows
313-
* XP and 256KB on Vista, no such cap is placed on writes to
314-
* files over the network on Windows XP. Unfortunately, there
315-
* seems to be a limit of 32MB-28KB on X64 and 64MB-32KB on x86;
316-
* bigger writes fail on Windows XP.
317-
* So we cap to a nice 31MB here to avoid write failures over
318-
* the net without changing the number of WriteFile() calls in
319-
* the local case.
320-
*/
321-
return write(fd, buf, min(count, 31 * 1024 * 1024));
322-
}
323-
324307
static BOOL WINAPI ctrl_ignore(DWORD type)
325308
{
326309
return TRUE;

compat/mingw.h

-3
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ int mingw_rmdir(const char *path);
180180
int mingw_open (const char *filename, int oflags, ...);
181181
#define open mingw_open
182182

183-
ssize_t mingw_write(int fd, const void *buf, size_t count);
184-
#define write mingw_write
185-
186183
int mingw_fgetc(FILE *stream);
187184
#define fgetc mingw_fgetc
188185

streaming.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ int stream_blob_to_fd(int fd, unsigned const char *sha1, struct stream_filter *f
538538
goto close_and_exit;
539539
}
540540
if (kept && (lseek(fd, kept - 1, SEEK_CUR) == (off_t) -1 ||
541-
write(fd, "", 1) != 1))
541+
xwrite(fd, "", 1) != 1))
542542
goto close_and_exit;
543543
result = 0;
544544

transport-helper.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1135,9 +1135,8 @@ static int udt_do_write(struct unidirectional_transfer *t)
11351135
return 0; /* Nothing to write. */
11361136

11371137
transfer_debug("%s is writable", t->dest_name);
1138-
bytes = write(t->dest, t->buf, t->bufuse);
1139-
if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&
1140-
errno != EINTR) {
1138+
bytes = xwrite(t->dest, t->buf, t->bufuse);
1139+
if (bytes < 0 && errno != EWOULDBLOCK) {
11411140
error("write(%s) failed: %s", t->dest_name, strerror(errno));
11421141
return -1;
11431142
} else if (bytes > 0) {

0 commit comments

Comments
 (0)