git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Dan McGregor <dan.mcgregor@usask.ca>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2] git-compat-util: undefine fileno if defined
Date: Tue, 12 Feb 2019 21:14:41 +0700	[thread overview]
Message-ID: <CACsJy8Dp+PV-Y=WGbr4bfNdK6zi+qBE5b6Etc+8ZvgDBYWBLjA@mail.gmail.com> (raw)
In-Reply-To: <20190212134537.GA26137@ash>

On Tue, Feb 12, 2019 at 8:45 PM Duy Nguyen <pclouds@gmail.com> wrote:
>
> 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

  reply	other threads:[~2019-02-12 14:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 19:30 [PATCH] http: cast result to FILE * Dan McGregor
2019-02-01 21:17 ` Junio C Hamano
2019-02-02 11:21   ` Duy Nguyen
2019-02-04 11:44     ` Johannes Schindelin
2019-02-04 12:13       ` Duy Nguyen
2019-02-04 18:10         ` Junio C Hamano
2019-02-05  1:36           ` Dan McGregor
2019-02-09  2:36 ` [PATCH v2] git-compat-util: undefine fileno if defined Dan McGregor
2019-02-09 18:34   ` Junio C Hamano
2019-02-12 13:45   ` Duy Nguyen
2019-02-12 14:14     ` Duy Nguyen [this message]
2019-02-12 16:56     ` Junio C Hamano
2019-02-16  2:33     ` Dan McGregor
2019-05-08  7:46       ` Junio C Hamano
2019-05-08 10:09         ` Duy Nguyen
2019-05-08 10:16           ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='CACsJy8Dp+PV-Y=WGbr4bfNdK6zi+qBE5b6Etc+8ZvgDBYWBLjA@mail.gmail.com' \
    --to=pclouds@gmail.com \
    --cc=dan.mcgregor@usask.ca \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).