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

Re: [cgit PATCH] Close file descriptor on error in readfile()

From
Rys Sommefeldt <rys@pixeltards.com>
Date
Nov 7, 2009, 02:26 UTC
Message-ID
<4AF4DAC9.3020805@pixeltards.com>
In-Reply-To
<f488382f0911061822y7d0b52d5sa5cf4b199554312f@mail.gmail.com>
Steven Noonan wrote:
> The above change looks bogus. If fd == -1, you close() it anyway?
>   
Ah, of course, sorry.  I'll redo the patch.
Show 22 quoted lines
>> +    if (fstat(fd, &st)) {
>> +        close(fd);
>>        return errno;
>> +    }
>>    if (!S_ISREG(st.st_mode))
>>        return EISDIR;
>>    *buf = xmalloc(st.st_size + 1);
>>    *size = read_in_full(fd, *buf, st.st_size);
>>    (*buf)[*size] = '\0';
>> +    close(fd);
>>    return (*size == st.st_size ? 0 : errno);
>> }
>> --
>> 1.6.5.2
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>     
> --
>   
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4580 (20091106) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
Previous: Steven NoonanNext: Rys Sommefeldt
Message 3 of 7 in “Close file descriptor on error in readfile()”
  1. Close file descriptor on error in readfile()Rys Sommefeldt, Nov 7, 2009
  2. Steven NoonanNov 7, 2009
  3. Rys SommefeldtNov 7, 2009
  4. Rys SommefeldtNov 7, 2009
  5. Lars HjemliNov 7, 2009
  6. Andreas SchwabNov 7, 2009
  7. Lars HjemliNov 7, 2009

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.