Re: add missing semicolon to tree(3) example code

2013-02-17 Thread Otto Moerbeek
On Mon, Feb 18, 2013 at 12:11:37AM +0100, Mark Kettenis wrote:

> > Date: Sun, 17 Feb 2013 18:45:10 +0100
> > From: Otto Moerbeek 
> > 
> > On Sun, Feb 17, 2013 at 03:59:41PM +0100, Franco Fichtner wrote:
> > 
> > > Hi all,
> > > 
> > > found this still lingering in my tree. Still trying to figure out
> > > the best workflow for sending patches. Not sure if this adheres
> > > to the standards.
> > > 
> > > Thanks,
> > > Franco
> > > ---
> > >  share/man/man3/tree.3 | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/share/man/man3/tree.3 b/share/man/man3/tree.3
> > > index bb9a5b2..f4a410c 100644
> > > --- a/share/man/man3/tree.3
> > > +++ b/share/man/man3/tree.3
> > > @@ -499,7 +499,7 @@ intcmp(struct node *e1, struct node *e2)
> > >  }
> > >  
> > >  RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
> > > -RB_GENERATE(inttree, node, entry, intcmp)
> > > +RB_GENERATE(inttree, node, entry, intcmp);
> > >  
> > >  int testdata[] = {
> > >   20, 16, 17, 13, 3, 6, 1, 8, 2, 4, 10, 19, 5, 9, 12, 15, 18,
> > > -- 
> > 
> > I don't agree. RB_GENERATE creates a function definition, and those are
> > not followed by a semicolon. It would just create an empty declaration.
> 
> On the other hand adding the semicolon helps editors to auto-indent
> the code.

emacs does not seem to have problems without a smeicolon 

anyway, some complers (using specific options) will complain about this.
e.g.  gcc --pedantic:

x.c:18: warning: ISO C does not allow extra ';' outside of a function

-Otto



Re: add missing semicolon to tree(3) example code

2013-02-17 Thread Mark Kettenis
> Date: Sun, 17 Feb 2013 18:45:10 +0100
> From: Otto Moerbeek 
> 
> On Sun, Feb 17, 2013 at 03:59:41PM +0100, Franco Fichtner wrote:
> 
> > Hi all,
> > 
> > found this still lingering in my tree. Still trying to figure out
> > the best workflow for sending patches. Not sure if this adheres
> > to the standards.
> > 
> > Thanks,
> > Franco
> > ---
> >  share/man/man3/tree.3 | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/share/man/man3/tree.3 b/share/man/man3/tree.3
> > index bb9a5b2..f4a410c 100644
> > --- a/share/man/man3/tree.3
> > +++ b/share/man/man3/tree.3
> > @@ -499,7 +499,7 @@ intcmp(struct node *e1, struct node *e2)
> >  }
> >  
> >  RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
> > -RB_GENERATE(inttree, node, entry, intcmp)
> > +RB_GENERATE(inttree, node, entry, intcmp);
> >  
> >  int testdata[] = {
> > 20, 16, 17, 13, 3, 6, 1, 8, 2, 4, 10, 19, 5, 9, 12, 15, 18,
> > -- 
> 
> I don't agree. RB_GENERATE creates a function definition, and those are
> not followed by a semicolon. It would just create an empty declaration.

On the other hand adding the semicolon helps editors to auto-indent
the code.



Re: add missing semicolon to tree(3) example code

2013-02-17 Thread Franco Fichtner
On Feb 17, 2013, at 6:45 PM, Otto Moerbeek  wrote:

> On Sun, Feb 17, 2013 at 03:59:41PM +0100, Franco Fichtner wrote:
> 
>> Hi all,
>> 
>> found this still lingering in my tree. Still trying to figure out
>> the best workflow for sending patches. Not sure if this adheres
>> to the standards.
>> 
>> Thanks,
>> Franco
>> ---
>> share/man/man3/tree.3 | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/share/man/man3/tree.3 b/share/man/man3/tree.3
>> index bb9a5b2..f4a410c 100644
>> --- a/share/man/man3/tree.3
>> +++ b/share/man/man3/tree.3
>> @@ -499,7 +499,7 @@ intcmp(struct node *e1, struct node *e2)
>> }
>> 
>> RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
>> -RB_GENERATE(inttree, node, entry, intcmp)
>> +RB_GENERATE(inttree, node, entry, intcmp);
>> 
>> int testdata[] = {
>>  20, 16, 17, 13, 3, 6, 1, 8, 2, 4, 10, 19, 5, 9, 12, 15, 18,
>> -- 
> 
> I don't agree. RB_GENERATE creates a function definition, and those are
> not followed by a semicolon. It would just create an empty declaration.

Ok, I wasn't stating it's strictly necessary. It's just that most of
the lines implementing splay or rb trees are using the semicolon.

It implies knowledge of the underlying code to leave the semicolon out
just for this particular macro; and the man page shows a semicolon in
the synopsis section regardless.

> As for sending diff, I (and quite some people here) prefer cvs diff -p
> on a checked out tree, it shows which version you diffed against.

Alright, thanks, I'll see what I can do on my real OpenBSD box. FWIW,
this diff was based on -current.


Franco



Re: add missing semicolon to tree(3) example code

2013-02-17 Thread Otto Moerbeek
On Sun, Feb 17, 2013 at 03:59:41PM +0100, Franco Fichtner wrote:

> Hi all,
> 
> found this still lingering in my tree. Still trying to figure out
> the best workflow for sending patches. Not sure if this adheres
> to the standards.
> 
> Thanks,
> Franco
> ---
>  share/man/man3/tree.3 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/share/man/man3/tree.3 b/share/man/man3/tree.3
> index bb9a5b2..f4a410c 100644
> --- a/share/man/man3/tree.3
> +++ b/share/man/man3/tree.3
> @@ -499,7 +499,7 @@ intcmp(struct node *e1, struct node *e2)
>  }
>  
>  RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
> -RB_GENERATE(inttree, node, entry, intcmp)
> +RB_GENERATE(inttree, node, entry, intcmp);
>  
>  int testdata[] = {
>   20, 16, 17, 13, 3, 6, 1, 8, 2, 4, 10, 19, 5, 9, 12, 15, 18,
> -- 

I don't agree. RB_GENERATE creates a function definition, and those are
not followed by a semicolon. It would just create an empty declaration.

As for sending diff, I (and quite some people here) prefer cvs diff -p
on a checked out tree, it shows which version you diffed against.

-Otto




add missing semicolon to tree(3) example code

2013-02-17 Thread Franco Fichtner
Hi all,

found this still lingering in my tree. Still trying to figure out
the best workflow for sending patches. Not sure if this adheres
to the standards.

Thanks,
Franco
---
 share/man/man3/tree.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/share/man/man3/tree.3 b/share/man/man3/tree.3
index bb9a5b2..f4a410c 100644
--- a/share/man/man3/tree.3
+++ b/share/man/man3/tree.3
@@ -499,7 +499,7 @@ intcmp(struct node *e1, struct node *e2)
 }
 
 RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
-RB_GENERATE(inttree, node, entry, intcmp)
+RB_GENERATE(inttree, node, entry, intcmp);
 
 int testdata[] = {
20, 16, 17, 13, 3, 6, 1, 8, 2, 4, 10, 19, 5, 9, 12, 15, 18,
--