From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id E72E821CE8 for ; Tue, 16 Apr 2024 15:42:49 +0200 (CEST) Received: (qmail 23919 invoked by uid 550); 16 Apr 2024 13:42:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 23883 invoked from network); 16 Apr 2024 13:42:44 -0000 Date: Tue, 16 Apr 2024 09:42:57 -0400 From: Rich Felker To: Michael Forney Cc: Jens Gustedt , musl@lists.openwall.com Message-ID: <20240416134256.GG4163@brightrain.aerifal.cx> References: <20240319151202.6856ebec@inria.fr> <29L5XTRHVUHVF.2NI3H53T4EFFS@mforney.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29L5XTRHVUHVF.2NI3H53T4EFFS@mforney.org> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Re: [PATCH] C23: update some legacy function pointers On Mon, Apr 15, 2024 at 08:57:35PM -0700, Michael Forney wrote: > Jens Gustedt wrote: > > In C23, empty parameter lists loose their meaning as "function that > > may receive any number of parameters". > > > > When compiling with -std=c2x, there were three left-overs in musl that > > still used that. Change them to use the correct prototype, since it is > > available at all these places, anyhow. > > I think there's one more: > > diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c > index 8294598b..e05f1623 100644 > --- a/src/process/posix_spawn.c > +++ b/src/process/posix_spawn.c > @@ -149,7 +149,7 @@ static int child(void *args_vp) > ? &attr->__mask : &args->oldmask, 0); > > int (*exec)(const char *, char *const *, char *const *) = > - attr->__fn ? (int (*)())attr->__fn : execve; > + attr->__fn ? (int (*)(const char *, char *const *, char *const *))attr->__fn : execve; > > exec(args->path, args->argv, args->envp); > ret = -errno; > > Perhaps it's better to solve this by changing the type of __fn in > posix_spawnattr_t from void * to the appropriate function type, but > since this is in a public header, I'm not sure if it somehow breaks > something: > > diff --git a/include/spawn.h b/include/spawn.h > index 8eb73e00..fec1280d 100644 > --- a/include/spawn.h > +++ b/include/spawn.h > @@ -29,7 +29,7 @@ typedef struct { > pid_t __pgrp; > sigset_t __def, __mask; > int __prio, __pol; > - void *__fn; > + int (*__fn)(const char *, char *const *, char *const *); > char __pad[64-sizeof(void *)]; > } posix_spawnattr_t; > > diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c > index 8294598b..2611fb94 100644 > --- a/src/process/posix_spawn.c > +++ b/src/process/posix_spawn.c > @@ -149,7 +149,7 @@ static int child(void *args_vp) > ? &attr->__mask : &args->oldmask, 0); > > int (*exec)(const char *, char *const *, char *const *) = > - attr->__fn ? (int (*)())attr->__fn : execve; > + attr->__fn ? attr->__fn : execve; > > exec(args->path, args->argv, args->envp); > ret = -errno; > diff --git a/src/process/posix_spawnp.c b/src/process/posix_spawnp.c > index aad6133b..28ef1aa4 100644 > --- a/src/process/posix_spawnp.c > +++ b/src/process/posix_spawnp.c > @@ -8,6 +8,6 @@ int posix_spawnp(pid_t *restrict res, const char *restrict file, > { > posix_spawnattr_t spawnp_attr = { 0 }; > if (attr) spawnp_attr = *attr; > - spawnp_attr.__fn = (void *)__execvpe; > + spawnp_attr.__fn = __execvpe; > return posix_spawn(res, file, fa, &spawnp_attr, argv, envp); > } It's intentional that public headers don't leak implementation internals, so the void * with cast back to function pointer type is preferred. Rich