Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Jan 2001 10:44:09 +0300 (MSK)
From:      Alex Kapranoff <alex@kapran.bitmcnit.bryansk.su>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   docs/24690: duplication in style.9
Message-ID:  <200101280744.f0S7i9d02935@kapran.bitmcnit.bryansk.su>

next in thread | raw e-mail | index | archive | help

>Number:         24690
>Category:       docs
>Synopsis:       duplication in style.9
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 28 00:00:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Alex Kapranoff
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD kapran.bitmcnit.bryansk.su 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Sat Jan 20 22:56:54 MSK 2001 root@kapran.bitmcnit.bryansk.su:/usr/obj/usr/src/sys/KAPRAN i386

>Description:
	style.9 manpage recomends against declaring functions inside
	other functions two times.  Look:

STYLE(9)	       FreeBSD Kernel Developer's Manual	      STYLE(9)

NAME
     style - Kernel source file style guide
[skip]
     When declaring variables in functions declare them sorted by size, then
     in alphabetical order; multiple ones per line are okay.  Declaring func-
     tions inside functions is not recommended, since their linkage scope is
     always global.  If a line overflows reuse the type keyword.

     Be careful to not obfuscate the code by initializing variables in the
     declarations.  Use this feature only thoughtfully.  DO NOT use function
     calls in initializers!

	     struct foo one, *two;
	     double three;
	     int *four, five;
	     char *six, seven, eight, nine, ten, eleven, twelve;

	     four = myfunction();

     Do not declare functions inside other functions; ANSI C says that such
     declarations have file scope regardless of the nesting of the declara-
     tion.  Hiding file declarations in what appears to be a local scope is
     undesirable and will elicit complaints from a good compiler.

>How-To-Repeat:
	
>Fix:

*** /usr/src/share/man/man9/style.9	Fri Dec 29 19:07:03 2000
--- style.9	Sun Jan 28 10:37:12 2001
***************
*** 382,390 ****
  .Pp
  When declaring variables in functions declare them sorted by size,
  then in alphabetical order; multiple ones per line are okay.
! Declaring functions inside functions is not recommended, since their
! linkage scope is always global.  If a line overflows reuse the type
! keyword.
  .Pp
  Be careful to not obfuscate the code by initializing variables in
  the declarations.  Use this feature only thoughtfully.
--- 382,388 ----
  .Pp
  When declaring variables in functions declare them sorted by size,
  then in alphabetical order; multiple ones per line are okay.
! If a line overflows reuse the type keyword.
  .Pp
  Be careful to not obfuscate the code by initializing variables in
  the declarations.  Use this feature only thoughtfully.

>Release-Note:
>Audit-Trail:
>Unformatted:


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




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