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

Re: [PATCH 1/2] git_mkstemps: correctly test return value of open()

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 18, 2013, 17:47 UTC
Message-ID
<7vzjtj3gl4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v4nbr4v7m.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> Drew Northup <n1xim.email@gmail.com> writes:
>
>> I presume that I should apply this change to my porting of
>> git_mkstemps_mode() to tig. If there are no complaints about this for
>> a couple of days I will do so.
>
> Hmph, Thomas and I were actually asking you to give us
>
> 	Signed-off-by: Drew Northup <n1xim.email@gmail.com>

Gaahhh, I need a bit more caffeine. Somehow I mixed up Dale and Drew.

Sorry for the noise.  Please ignore.
Show 41 quoted lines
> for the patch in question.  If tig has the same issue, applying that
> same patch there may make sense, but that is an independent issue.
>
> Thanks.
>
>>
>> REF: $gmane/229961
>>
>> On 07/17/2013 03:29 PM, Junio C Hamano wrote:
>>> Thomas Rast<trast@inf.ethz.ch>  writes:
>>>> Thomas Rast<trast@inf.ethz.ch>  writes:
>>>>> From: "Dale R. Worley"<worley@alum.mit.edu>
>>>>>
>>>>> open() returns -1 on failure, and indeed 0 is a possible success value
>>>>> if the user closed stdin in our process.  Fix the test.
>>>>>
>>>>> Signed-off-by: Thomas Rast<trast@inf.ethz.ch>
>>
>>>>>   wrapper.c | 2 +-
>>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/wrapper.c b/wrapper.c
>>>>> index dd7ecbb..6a015de 100644
>>>>> --- a/wrapper.c
>>>>> +++ b/wrapper.c
>>>>> @@ -322,7 +322,7 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
>>>>>   		template[5] = letters[v % num_letters]; v /= num_letters;
>>>>>
>>>>>   		fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
>>>>> -		if (fd>  0)
>>>>> +		if (fd>= 0)
>>>>>   			return fd;
>>>>>   		/*
>>>>>   		 * Fatal error (EPERM, ENOSPC etc).
>>
>>
>> --
>> -Drew Northup
>> --------------------------------------------------------------
>> "As opposed to vegetable or mineral error?"
>> -John Pescatore, SANS NewsBites Vol. 12 Num. 59
Previous: Junio C HamanoNext: Dale R. Worley
Message 7 of 16 in “open() error checking”
  1. 0/2 open() error checkingThomas Rast, Jul 12, 2013
  2. 1/2 git_mkstemps: correctly test return value of open()Thomas Rast, Jul 12, 2013
  3. Thomas RastJul 16, 2013
  4. Junio C HamanoJul 17, 2013
  5. Drew NorthupJul 18, 2013
  6. Junio C HamanoJul 18, 2013
  7. Junio C HamanoJul 18, 2013
  8. Dale R. WorleyJul 18, 2013
  9. Eric SunshineJul 18, 2013
  10. Junio C HamanoJul 18, 2013
  11. Dale R. WorleyJul 18, 2013
  12. Junio C HamanoJul 18, 2013
  13. Dale R. WorleyJul 18, 2013
  14. 2/2 run-command: dup_devnull(): guard against syscalls failingThomas Rast, Jul 12, 2013
  15. Junio C HamanoJul 12, 2013
  16. Thomas RastJul 16, 2013

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.