git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Fix checkout of large files to network shares under Windows XP

From
Sebastian Schuberth <sschuberth@gmail.com>
Date
Apr 20, 2010, 14:21 UTC
Message-ID
<i2kbdca99241004200721l7cbd0052oa6921533f7efb8a4@mail.gmail.com>
In-Reply-To
<4BCDA49C.4090405@viscovery.net>
On Tue, Apr 20, 2010 at 14:57, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 13 quoted lines
> Am 4/20/2010 14:42, schrieb Sebastian Schuberth:
>> On Mon, Apr 19, 2010 at 22:43, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
>>> Shouldn't the loop be left in the successful case, too?  write(2) is
>>> allowed to write less than requested, so the caller already needs to
>>> deal with that case anyway.
>>
>> I prefer to make the wrapper as transparent as possible. If a direct
>> call to write would not write less than requested, the wrapper should
>> not either.
>
> Sure, but René meant the opposite case: When fewer bytes than requested
> were written, then you shouldn't retry to write more! That is, you should
> exit the loop when write(fd, buf, n) does not return n.

I see what you mean, but I do not fully agree. Who guarantees that (on some obscure OS) a following call to write(fd, buf, n) will not return n again, maybe because write() temporarily decided to write fewer bytes than requested to make the next write() call do aligned writes to something? That case then is probably already handled in the caller to write(), but at least my code is not wrong in that respect.

> I still find your code unnecessarily hard to read. In particular, you
> should extract the non-problematic case out of the loop. If you followed
> my suggestion elsewhere in the thread, you wouldn't have to write any
> conditionals that 'break' out of a loop.

I didn't follow your suggestion on purpose because I experimented with it and I found *yours* to be hard to read. It has three calls to write() and more places where errors need to be checked. As I do not have the will to waste more time on style discussions about code that fixes other people's issues, and not the time to test the code on Windows XP over and over again, I hope you are willing to accept code that is different from how you would have written it. So it's take it or leave it (or modify it yourself, if you feel like it).

-- 
Sebastian Schuberth
Previous: Johannes SixtNext: René Scharfe
Message 9 of 15 in “Fix checkout of large files to network shares under Windows XP”
  1. Fix checkout of large files to network shares under Windows XPSebastian Schuberth, Apr 19, 2010
  2. Junio C HamanoApr 19, 2010
  3. Johannes SchindelinApr 20, 2010
  4. René ScharfeApr 19, 2010
  5. Albert DvornikApr 19, 2010
  6. Johannes SixtApr 20, 2010
  7. Sebastian SchuberthApr 20, 2010
  8. Johannes SixtApr 20, 2010
  9. Sebastian SchuberthApr 20, 2010
  10. René ScharfeApr 20, 2010
  11. René ScharfeApr 29, 2010
  12. Johannes SixtApr 30, 2010
  13. Sebastian SchuberthApr 30, 2010
  14. René ScharfeOct 16, 2010
  15. Dmitry PotapovOct 17, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.