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

Re: [PATCH] compat: convert modes to use portable file type values

From
David Michael <fedora.dm0@gmail.com>
Date
Dec 1, 2014, 17:49 UTC
Message-ID
<CAEvUa7mhjG1xPoJedp4XYrxr39_EuzvGtONLv0B=uBw+vQB5pw@mail.gmail.com>
In-Reply-To
<CACsJy8CKEwOVcB_MUaK8mmSmQuKHC6R6K0YymjCrTP3aYFdbPg@mail.gmail.com>
On Mon, Dec 1, 2014 at 9:44 AM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 8 quoted lines
> On Sun, Nov 30, 2014 at 9:41 AM, David Michael <fedora.dm0@gmail.com> wrote:
>> +int git_stat(const char *path, struct stat *buf)
>> +{
>> +       int rc;
>> +       rc = stat(path, buf);
>> +       if (buf != NULL)
>
> It's a minor thing, but maybe test "!rc" instead of "buf != NULL"?
Okay, it makes sense to only do the conversion for a successful return code.

Should it test for both a zero return code and a non-null pointer? I don't know if there are any cases where passing a null pointer is legal. The standard doesn't seem to explicitly forbid it. z/OS returns -1 and sets errno to EFAULT when stat() is given NULL, but this patch should be able to be used on any platform.

David
Previous: Duy NguyenNext: Junio C Hamano
Message 9 of 12 in “compat: convert modes to use portable file type values”
  1. compat: convert modes to use portable file type valuesDavid Michael, Nov 30, 2014
  2. Torsten BögershausenNov 30, 2014
  3. David MichaelDec 1, 2014
  4. Torsten BögershausenDec 1, 2014
  5. David MichaelDec 1, 2014
  6. David MichaelDec 1, 2014
  7. Junio C HamanoDec 1, 2014
  8. Duy NguyenDec 1, 2014
  9. David MichaelDec 1, 2014
  10. Junio C HamanoDec 1, 2014
  11. David MichaelDec 1, 2014
  12. Junio C HamanoDec 1, 2014

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.