From nobody@FreeBSD.org  Wed Mar 20 22:30:23 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id F2E5FB9E
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 20 Mar 2013 22:30:22 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id CB0A18BD
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 20 Mar 2013 22:30:22 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r2KMUMwV002494
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 20 Mar 2013 22:30:22 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r2KMUM9u002492;
	Wed, 20 Mar 2013 22:30:22 GMT
	(envelope-from nobody)
Message-Id: <201303202230.r2KMUM9u002492@red.freebsd.org>
Date: Wed, 20 Mar 2013 22:30:22 GMT
From: hiren panchasara <hiren.panchasara@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Fixing clang warnings at /sys/dev/ips
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         177164
>Category:       kern
>Synopsis:       [patch] Fixing clang warnings at /sys/dev/ips
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    hiren
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 20 22:40:00 UTC 2013
>Closed-Date:    Sun Apr 14 03:30:43 UTC 2013
>Last-Modified:  Wed Apr 17 21:30:00 UTC 2013
>Originator:     hiren panchasara
>Release:        current
>Organization:
>Environment:
10.0-CURRENT FreeBSD 10.0-CURRENT #1 r248555: Wed Mar 20 15:00:20 UTC 2013
>Description:
===> ips (all)
/usr/src/sys/modules/ips/../../dev/ips/ips.c:582:13: warning: variable 'dmamap' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]   
        if (bus_dma_tag_create( /* parent    */ sc->adapter_dmatag,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/src/sys/modules/ips/../../dev/ips/ips.c:626:44: note: uninitialized use occurs here
        bus_dmamem_free(dmatag, sc->copper_queue, dmamap);
                                                  ^~~~~~
/usr/src/sys/modules/ips/../../dev/ips/ips.c:582:9: note: remove the 'if' if its condition is always false
        if (bus_dma_tag_create( /* parent    */ sc->adapter_dmatag,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/src/sys/modules/ips/../../dev/ips/ips.c:581:21: note: initialize the variable 'dmamap' to silence this warning
        bus_dmamap_t dmamap;
                           ^
                            = NULL
1 warning generated.

>How-To-Repeat:
cd /sys/modules/ips and do "make" to see clang warnings.
>Fix:
Index: sys/dev/ips/ips.c
===================================================================
--- sys/dev/ips/ips.c   (revision 248555)
+++ sys/dev/ips/ips.c   (working copy)
@@ -578,7 +578,7 @@
 {
        int error;
        bus_dma_tag_t dmatag;
-       bus_dmamap_t dmamap;
+       bus_dmamap_t dmamap = NULL;
                if (bus_dma_tag_create( /* parent    */ sc->adapter_dmatag,
                                /* alignemnt */ 1,
                                /* boundary  */ 0,

>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/177164: commit references a PR
Date: Sun, 14 Apr 2013 02:42:47 +0000 (UTC)

 Author: hiren
 Date: Sun Apr 14 02:42:40 2013
 New Revision: 249461
 URL: http://svnweb.freebsd.org/changeset/base/249461
 
 Log:
   Fixing a clang warning indicating uninitialized variable usage.
   
   PR:	kern/177164
   Approved by:	sbruno (mentor)
 
 Modified:
   head/sys/dev/ips/ips.c
 
 Modified: head/sys/dev/ips/ips.c
 ==============================================================================
 --- head/sys/dev/ips/ips.c	Sun Apr 14 02:26:12 2013	(r249460)
 +++ head/sys/dev/ips/ips.c	Sun Apr 14 02:42:40 2013	(r249461)
 @@ -578,7 +578,7 @@ static int ips_copperhead_queue_init(ips
  {
  	int error;
  	bus_dma_tag_t dmatag;
 -	bus_dmamap_t dmamap;
 +	bus_dmamap_t dmamap = NULL;
         	if (bus_dma_tag_create(	/* parent    */	sc->adapter_dmatag,
  				/* alignemnt */	1,
  				/* boundary  */	0,
 _______________________________________________
 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"
 
State-Changed-From-To: open->closed 
State-Changed-By: hiren 
State-Changed-When: Sun Apr 14 03:30:00 UTC 2013 
State-Changed-Why:  
Changes committed; closing the PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=177164 
Responsible-Changed-From-To: freebsd-bugs->hiren 
Responsible-Changed-By: hiren 
Responsible-Changed-When: Mon Apr 15 19:48:29 UTC 2013 
Responsible-Changed-Why:  
Marking myself as "responsible". 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/177164: commit references a PR
Date: Wed, 17 Apr 2013 21:21:40 +0000 (UTC)

 Author: hiren
 Date: Wed Apr 17 21:21:27 2013
 New Revision: 249595
 URL: http://svnweb.freebsd.org/changeset/base/249595
 
 Log:
   Improving r249461 by providing a better way to handle the clang warning.
   
   PR:		kern/177164
   Reviewed by:	jhb
   Approved by:	sbruno (mentor)
 
 Modified:
   head/sys/dev/ips/ips.c
 
 Modified: head/sys/dev/ips/ips.c
 ==============================================================================
 --- head/sys/dev/ips/ips.c	Wed Apr 17 21:08:18 2013	(r249594)
 +++ head/sys/dev/ips/ips.c	Wed Apr 17 21:21:27 2013	(r249595)
 @@ -578,7 +578,7 @@ static int ips_copperhead_queue_init(ips
  {
  	int error;
  	bus_dma_tag_t dmatag;
 -	bus_dmamap_t dmamap = NULL;
 +	bus_dmamap_t dmamap;
         	if (bus_dma_tag_create(	/* parent    */	sc->adapter_dmatag,
  				/* alignemnt */	1,
  				/* boundary  */	0,
 @@ -595,7 +595,7 @@ static int ips_copperhead_queue_init(ips
  				&dmatag) != 0) {
                  device_printf(sc->dev, "can't alloc dma tag for statue queue\n");
  		error = ENOMEM;
 -		goto exit;
 +		return error;
          }
  	if(bus_dmamem_alloc(dmatag, (void *)&(sc->copper_queue), 
  	   		    BUS_DMA_NOWAIT, &dmamap)){
 @@ -623,7 +623,8 @@ static int ips_copperhead_queue_init(ips
  	
  	return 0;
  exit:
 -	bus_dmamem_free(dmatag, sc->copper_queue, dmamap);
 +	if (sc->copper_queue != NULL)
 +		bus_dmamem_free(dmatag, sc->copper_queue, dmamap);
  	bus_dma_tag_destroy(dmatag);
  	return error;
  }
 _______________________________________________
 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:
