All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rys Sommefeldt <rys@pixeltards.com>
To: Steven Noonan <steven@uplinklabs.net>
Cc: git@vger.kernel.org
Subject: Re: [cgit PATCH] Close file descriptor on error in readfile()
Date: Sat, 07 Nov 2009 02:26:17 +0000	[thread overview]
Message-ID: <4AF4DAC9.3020805@pixeltards.com> (raw)
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.
>> +    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

  reply	other threads:[~2009-11-07  2:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-07  2:01 [cgit PATCH] Close file descriptor on error in readfile() Rys Sommefeldt
2009-11-07  2:22 ` Steven Noonan
2009-11-07  2:26   ` Rys Sommefeldt [this message]
2009-11-07 12:23 ` Rys Sommefeldt
2009-11-07 14:59   ` Lars Hjemli
2009-11-07 16:14     ` Andreas Schwab
2009-11-07 17:15       ` Lars Hjemli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AF4DAC9.3020805@pixeltards.com \
    --to=rys@pixeltards.com \
    --cc=git@vger.kernel.org \
    --cc=steven@uplinklabs.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.