From nobody@FreeBSD.org  Mon Jun 10 16:58:04 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id F3468C29
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 10 Jun 2013 16:58:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	by mx1.freebsd.org (Postfix) with ESMTP id C6CE41469
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 10 Jun 2013 16:58:03 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r5AGw3EM041313
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 10 Jun 2013 16:58:03 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r5AGw3J8041312;
	Mon, 10 Jun 2013 16:58:03 GMT
	(envelope-from nobody)
Message-Id: <201306101658.r5AGw3J8041312@oldred.freebsd.org>
Date: Mon, 10 Jun 2013 16:58:03 GMT
From: Yanhui Shen <shen.elf@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: the example function in filemon(4) should have a return value
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         179459
>Category:       docs
>Synopsis:       the example function in filemon(4) should have a return value
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pluknet
>State:          patched
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 10 17:00:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Fri Jun 14 08:30:00 UTC 2013
>Originator:     Yanhui Shen
>Release:        FreeBSD 9.1-STABLE
>Organization:
>Environment:
FreeBSD ThinkPad 9.1-STABLE FreeBSD 9.1-STABLE #0 r251600: Mon Jun 10 21:49:57 CST 2013     root@ThinkPad:/usr/obj/usr/src/sys/ThinkPad  amd64
>Description:
man filemon

The function is "static void open_filemon(void)",
but there are "return 0"s.
>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: pluknet 
State-Changed-When: Fri Jun 14 08:28:23 UTC 2013 
State-Changed-Why:  
Fix committed to head, thanks for report. 


Responsible-Changed-From-To: freebsd-doc->pluknet 
Responsible-Changed-By: pluknet 
Responsible-Changed-When: Fri Jun 14 08:28:23 UTC 2013 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=179459 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/179459: commit references a PR
Date: Fri, 14 Jun 2013 08:28:20 +0000 (UTC)

 Author: pluknet
 Date: Fri Jun 14 08:28:08 2013
 New Revision: 251744
 URL: http://svnweb.freebsd.org/changeset/base/251744
 
 Log:
   Fix and improve filemon(4) example:
   - remove return statements from void function [1]
   - include missing header
   - use O_CLOEXEC instead of separate fcntl() calls
   
   PR:		docs/179459 [1]
   MFC after:	1 week
 
 Modified:
   head/share/man/man4/filemon.4
 
 Modified: head/share/man/man4/filemon.4
 ==============================================================================
 --- head/share/man/man4/filemon.4	Fri Jun 14 08:26:58 2013	(r251743)
 +++ head/share/man/man4/filemon.4	Fri Jun 14 08:28:08 2013	(r251744)
 @@ -31,7 +31,7 @@
  .\"
  .\" $FreeBSD$
  .\"
 -.Dd May 30, 2012
 +.Dd June 14, 2013
  .Dt FILEMON 4
  .Os
  .Sh NAME
 @@ -126,6 +126,7 @@ is set to indicate the error.
  #include <dev/filemon/filemon.h>
  #include <fcntl.h>
  #include <err.h>
 +#include <unistd.h>
  
  static void
  open_filemon(void)
 @@ -133,29 +134,24 @@ open_filemon(void)
  	pid_t child;
  	int fm_fd, fm_log;
  
 -	if ((fm_fd = open("/dev/filemon", O_RDWR)) == -1)
 +	if ((fm_fd = open("/dev/filemon", O_RDWR | O_CLOEXEC)) == -1)
  		err(1, "open(\e"/dev/filemon\e", O_RDWR)");
  	if ((fm_log = open("filemon.out",
 -	    O_CREAT | O_WRONLY | O_TRUNC, DEFFILEMODE)) == -1)
 +	    O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, DEFFILEMODE)) == -1)
  		err(1, "open(filemon.out)");
  
  	if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1)
  		err(1, "Cannot set filemon log file descriptor");
 -	/* Set up these two fd's to close on exec. */
 -	(void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC);
 -	(void)fcntl(fm_log, F_SETFD, FD_CLOEXEC);
  
  	if ((child = fork()) == 0) {
  		child = getpid();
  		if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1)
  			err(1, "Cannot set filemon PID");
  		/* Do something here. */
 -		return 0;
  	} else {
  		wait(&child);
  		close(fm_fd);
  	}
 -	return 0;
  }
  .Ed
  .Pp
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
