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

Re: [PATCH v2] git-compat-util: undefine fileno if defined

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 12, 2019, 14:14 UTC
Message-ID
<CACsJy8Dp+PV-Y=WGbr4bfNdK6zi+qBE5b6Etc+8ZvgDBYWBLjA@mail.gmail.com>
In-Reply-To
<20190212134537.GA26137@ash>
On Tue, Feb 12, 2019 at 8:45 PM Duy Nguyen <pclouds@gmail.com> wrote:
Show 11 quoted lines
>
> On Fri, Feb 08, 2019 at 08:36:21PM -0600, Dan McGregor wrote:
> > Commit 8dd2e88a92 ("http: support file handles for HTTP_KEEP_ERROR",
> > 2019-01-10) introduced an implicit assumption that rewind, fileno, and
> > fflush are functions. At least on FreeBSD fileno is not, and as such
> > passing a void * failed.
> >
> > All systems tested (FreeBSD and NetBSD) that define fineo as a macro
>
> OpenBSD or NetBSD? From this [1], it looks like OpenBSD fails while
> NetBSD compiles ok (and fails to run some tests)

According to this [2] looks like NetBSD is affected too, but only in no-thread mode. With pthreads, fileno is not redefined as a macro. That probably explains why it's ok from git-ci.

#define fileno(p) __sfileno(p)
#define __sfileno(p) \
    ((p)->_file == -1 ? -1 : (int)(unsigned short)(p)->_file)
[2] http://cvsweb.netbsd.org/bsdweb.cgi/src/include/stdio.h?rev=1.97&content-type=text/x-cvsweb-markup
> For the record, at least fbsd also defines feof, ferror, clearerr,
> getc and putc in the same way. But at least I don't see how something
> like feof(fp++) could cause bad side effects.

... and __sfileno (and other friends) can cause bad side effects, sigh. It's probably best to avoid fancy function calls.

-- 
Duy
Previous: Duy NguyenNext: Junio C Hamano
Message 11 of 16 in “http: cast result to FILE *”
  1. http: cast result to FILE *Dan McGregor, Feb 1, 2019
  2. Junio C HamanoFeb 1, 2019
  3. Duy NguyenFeb 2, 2019
  4. Johannes SchindelinFeb 4, 2019
  5. Duy NguyenFeb 4, 2019
  6. Junio C HamanoFeb 4, 2019
  7. Dan McGregorFeb 5, 2019
  8. git-compat-util: undefine fileno if definedDan McGregor, Feb 9, 2019
  9. Junio C HamanoFeb 9, 2019
  10. Duy NguyenFeb 12, 2019
  11. Duy NguyenFeb 12, 2019
  12. Junio C HamanoFeb 12, 2019
  13. Dan McGregorFeb 16, 2019
  14. Junio C HamanoMay 8, 2019
  15. Duy NguyenMay 8, 2019
  16. Junio C HamanoMay 8, 2019

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.