Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 10 Oct 2017 20:51:17 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: William Pitcock <nenolod@...eferenced.org>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH] stdio: implement fopencookie(3)

Hello William,

On Tue, 10 Oct 2017 18:03:56 +0000 William Pitcock
<nenolod@...eferenced.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 ::

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.