Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <21X298INFNZYP.3IQCAFJ55M1OH@mforney.org>
Date: Fri, 06 Mar 2026 13:22:58 -0800
From: Michael Forney <mforney@...rney.org>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH] mallocng: remove stray ';' at top-level

Rich Felker <dalias@...c.org> wrote:
> On Mon, Apr 15, 2024 at 03:26:17AM -0700, Michael Forney wrote:
> > The LOCK_OBJ_DEF macro ends with the closing brace of a
> > function-definition, which is a complete external-declaration. The
> > semicolon following the macro use is therefore unnecessary. Empty
> > declarations are not syntactically valid according to the ISO C
> > grammar, so remove it.
> > ---
> >  src/malloc/mallocng/malloc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/malloc/mallocng/malloc.c b/src/malloc/mallocng/malloc.c
> > index d695ab8e..2549eb38 100644
> > --- a/src/malloc/mallocng/malloc.c
> > +++ b/src/malloc/mallocng/malloc.c
> > @@ -7,7 +7,7 @@
> >  
> >  #include "meta.h"
> >  
> > -LOCK_OBJ_DEF;
> > +LOCK_OBJ_DEF
> >  
> >  const uint16_t size_classes[] = {
> >  	1, 2, 3, 4, 5, 6, 7, 8,
> > -- 
> > 2.44.0
> 
> This looks like a bug in how glue.h was written when mallocng was
> imported into musl; from the mallocng-draft repo, it's clear that the
> intent was for the declaration in LOCK_OBJ_DEF not to end in ; so that
> the code in malloc.c using the macro would be correct.

I see. The current definition of LOCK_OBJ_DEF is

	#define LOCK_OBJ_DEF \
	int __malloc_lock[1]; \
	void __malloc_atfork(int who) { malloc_atfork(who); }

So to fix this without changing the usage of LOCK_OBJ_DEF, we could
swap the order of those definitions, which would allow dropping the
semicolon from __malloc_lock instead.

I'll send an updated patch.

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.