Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Aug 2000 05:00:03 -0700 (PDT)
From:      Johan Karlsson <k@numeri.campus.luth.se>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/9869: Addition to style(9) about usage of macro. 
Message-ID:  <200008081200.FAA42059@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/9869; it has been noted by GNATS.

From: Johan Karlsson <k@numeri.campus.luth.se>
To: Bruce Evans <bde@zeta.org.au>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG, bde@FreeBSD.ORG
Subject: Re: kern/9869: Addition to style(9) about usage of macro. 
Date: Tue, 08 Aug 2000 13:58:54 +0200

 At Tue, 08 Aug 2000 05:10:18 +1000, Bruce Evans wrote:
 
 > Parts of it are poorly worded, especially "it makes it easier to read".
 > 
 > I made the following changes locally a long time ago:
 > 
 > diff -c2 style.9~ style.9
 > *** style.9~	Sun Jul 23 00:50:21 2000
 > --- style.9	Tue Aug  8 04:53:58 2000
 
 What do you think about the following addition to you patched version?
 
 Index: style.9
 ===================================================================
 RCS file: /home/ncvs/src/share/man/man9/style.9,v
 retrieving revision 1.37
 diff -u -r1.37 style.9
 --- style.9	2000/08/08 09:54:57	1.37
 +++ style.9	2000/08/08 11:40:15
 @@ -110,14 +110,16 @@
  and
  .Sq \&}
  .Pc .
 -Right-justify the
 -backslashes; it makes it easier to read.
 +Backslashes should be right-justified for easier reading.
  If the macro encapsulates a compound statement, enclose it in a
  .Dq Li do
  loop,
  so that it can safely be used in 
  .Dq Li if
  statements.
 +Decleration macro should be complete declerations and 
 +.Ql struck __hack  
 +should be used to require a statement-terminating semicolon.
  Any final statement-terminating semicolon should be
  supplied by the macro invocation rather than the macro, to make parsing easier
  for pretty-printers and editors.
 @@ -126,6 +128,11 @@
  	variable = (x) + (y);						\e
  	(y) += 2;							\e
  } while(0)
 +.Ed
 +.Bd -literal -offset 0i
 +#define	DECL(x, y)							\e
 +	struct example x = {y};						\e
 +	struct __hack
  .Ed
  .Pp
  Enumeration values are all uppercase.
 
 
 
 > > If it is enough, I think this PR 9869 can be closed.
 > 
 > The PR really asks for a semicolon to be added to most invocations of
 > SYSINIT().  This would currently add lots of pedantic syntax errors.
 > The hint in the man page about using "do ... while (0)" doesn't apply
 > because SYSINIT() is a declaration, not a statement.  My "struct __hack"
 > hack (menioned in the PR followup) can be used.
 
 
 If the above is accetable I think we should change the SYSINIT definition:
 Index: kernel.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/sys/kernel.h,v
 retrieving revision 1.65
 diff -u -r1.65 kernel.h
 --- kernel.h	2000/05/26 02:06:54	1.65
 +++ kernel.h	2000/08/08 11:45:48
 @@ -220,11 +220,13 @@
  		func,						\
  		ident						\
  	};							\
 -	DATA_SET(sysinit_set,uniquifier ## _sys_init);
 +	DATA_SET(sysinit_set,uniquifier ## _sys_init);		\
 +	struct __hack
  
  #define	SYSINIT(uniquifier, subsystem, order, func, ident)	\
  	C_SYSINIT(uniquifier, subsystem, order,			\
 -	(sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)ident)
 +	(sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)ident);	\
 +	struct __hack
  
  /*
   * Called on module unload: no special processing
 
 
 
 
 However this needs to be done carefully :-)
 
 My suggestion is
 1) change all SYSINIT(...) to SYSINIT(...);  approx 100 places
 	even thou this introduces -pedantic synatx error
 2) buildworld / kernel and make sure it still builds
 3) commit
 4) apply the above patch to sys/kernel.h which removes the 
 	-pedantic syntax error
 5) buildworld / kernel and make sure it still builds
 6) commit
 
 
 I can prepare patches for step 1) for -current and run it 
 throu a -current buildworld, but I run 4-Stable. And anyone 
 interested in commiting this should run it on a current for awhile.
 
 
 Does this sound like a good solution for this PR 
 (or is this to much fidling w/ holy stuff)?
 If not, close it and I spend my time with something else :-)
 
 /Johan K
 
 
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200008081200.FAA42059>