From: Jens Gustedt <jens.gustedt@inria.fr>
To: William Pitcock <nenolod@dereferenced.org>
Cc: musl@lists.openwall.com
Subject: Re: [PATCH] stdio: implement fopencookie(3)
Date: Tue, 10 Oct 2017 20:51:17 +0200 [thread overview]
Message-ID: <20171010205117.3deabfc7@inria.fr> (raw)
In-Reply-To: <20171010180356.11352-1-nenolod@dereferenced.org>
[-- Attachment #1: Type: text/plain, Size: 1771 bytes --]
Hello William,
On Tue, 10 Oct 2017 18:03:56 +0000 William Pitcock
<nenolod@dereferenced.org> wrote:
> The fopencookie(3) function allows the programmer to create a custom
> stdio implementation, using four hook functions which operate on a
> "cookie" data type.
I know it is not your fault, but the naming conventions in this new
interface are realy bad design.
> +typedef struct {
> + ssize_t (*read)(void *cookie, char *buf, size_t size);
> + ssize_t (*write)(void *cookie, const char *buf, size_t size);
> + int (*seek)(void *cookie, off_t *offset, int whence);
> + int (*close)(void *cookie);
> +} cookie_io_functions_t;
> +FILE *fopencookie(void *cookie, const char *mode, cookie_io_functions_t io_funcs);
The members may clash with macro names. E.g an implementation would be
allowed to overload "close" with a macro. This is not possible if the
implementation would want to use this interface here at the same time.
User code could legitimately want to use a macro "seek" for its own
purpose.
Could you at least avoid to use user-space names as function
parameters? Here you should just omit cookie, buf, size, offset,
whence, mode and io_funcs. I think in musl parameters in prototypes
usually don't have names. If you think that we should have them (they
sort of document the interface) you should put them into a reserved
namespace with leading underscore or so, or at least prefix them with
cookie_
Thanks
Jens
--
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536 ::
:: :::::::::::::::::::::: gsm France : +33 651400183 ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2017-10-10 18:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 18:03 William Pitcock
2017-10-10 18:51 ` Jens Gustedt [this message]
2017-10-10 20:56 ` Rich Felker
2017-10-10 21:40 ` Jens Gustedt
2017-10-11 2:08 ` Rich Felker
2017-10-11 5:51 ` Jens Gustedt
2017-10-10 22:58 ` Morten Welinder
2017-10-11 2:09 ` Rich Felker
-- strict thread matches above, loose matches on Subject: below --
2017-10-10 23:27 William Pitcock
2017-10-05 6:48 William Pitcock
2017-10-05 10:10 ` Szabolcs Nagy
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=20171010205117.3deabfc7@inria.fr \
--to=jens.gustedt@inria.fr \
--cc=musl@lists.openwall.com \
--cc=nenolod@dereferenced.org \
/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://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).