From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11993 Path: news.gmane.org!.POSTED!not-for-mail From: Jens Gustedt Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] stdio: implement fopencookie(3) Date: Tue, 10 Oct 2017 20:51:17 +0200 Organization: inria.fr Message-ID: <20171010205117.3deabfc7@inria.fr> References: <20171010180356.11352-1-nenolod@dereferenced.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/6tDoAiSbbHlFSzHF5V1bi9K"; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1507661493 6018 195.159.176.226 (10 Oct 2017 18:51:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 10 Oct 2017 18:51:33 +0000 (UTC) Cc: musl@lists.openwall.com To: William Pitcock Original-X-From: musl-return-12006-gllmg-musl=m.gmane.org@lists.openwall.com Tue Oct 10 20:51:29 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1e1zcj-0000mO-Kb for gllmg-musl@m.gmane.org; Tue, 10 Oct 2017 20:51:25 +0200 Original-Received: (qmail 14194 invoked by uid 550); 10 Oct 2017 18:51:30 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14176 invoked from network); 10 Oct 2017 18:51:30 -0000 X-IronPort-AV: E=Sophos;i="5.43,359,1503352800"; d="scan'208";a="295537425" In-Reply-To: <20171010180356.11352-1-nenolod@dereferenced.org> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) X-Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAACRQTFRFERslNjAsLTE9Ok9wUk9TaUs8iWhSrYZkj42Rz6aD3sGZ Xref: news.gmane.org gmane.linux.lib.musl.general:11993 Archived-At: --Sig_/6tDoAiSbbHlFSzHF5V1bi9K Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hello William, On Tue, 10 Oct 2017 18:03:56 +0000 William Pitcock 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 --=20 :: 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 :: --Sig_/6tDoAiSbbHlFSzHF5V1bi9K Content-Type: application/pgp-signature Content-Description: Digitale Signatur von OpenPGP -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQSN9stI2OFN1pLljN0P0+hp2tU34gUCWd0WpQAKCRAP0+hp2tU3 4quYAJ0UyuJxCFRvUjjvm2PL3NeYl04xOwCfRjLIJ9WGjAS7nfnJcN5I1zD9ENU= =iErh -----END PGP SIGNATURE----- --Sig_/6tDoAiSbbHlFSzHF5V1bi9K--