From nobody@FreeBSD.org  Wed Mar 20 20:06:03 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 952003E1
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 20 Mar 2013 20:06:03 +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 8569F18A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 20 Mar 2013 20:06:03 +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 r2KK63Mx071283
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 20 Mar 2013 20:06:03 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r2KK632x071282;
	Wed, 20 Mar 2013 20:06:03 GMT
	(envelope-from nobody)
Message-Id: <201303202006.r2KK632x071282@red.freebsd.org>
Date: Wed, 20 Mar 2013 20:06:03 GMT
From: hiren panchasara <hiren.panchasara@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Fixing clang warnings at /sys/dev/safe
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         177155
>Category:       kern
>Synopsis:       [patch] Fixing clang warnings at /sys/dev/safe
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    hiren
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 20 20:10:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Mon Apr 15 06:16:45 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:
===> safe (all)
/usr/src/sys/modules/safe/../../dev/safe/safe.c:1610:11: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
        while (j >= 0) {
               ~ ^  ~
/usr/src/sys/modules/safe/../../dev/safe/safe.c:1622:11: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
        while (j >= 0) {
               ~ ^  ~
2 warnings generated.

Proposed fix is replacing always true condition "j >= 0" with 1. I _hope_ this is the correct way to "fix" this.


>How-To-Repeat:
cd /sys/modules/safe and do "make" to see clang warnings.
>Fix:
Index: safe.c
===================================================================
--- safe.c      (revision 248555)
+++ safe.c      (working copy)
@@ -1607,7 +1607,7 @@
         * Advance src and dst to offset.
         */
        j = offset;
-       while (j >= 0) {
+       while (1) {
                if (srcm->m_len > j)
                        break;
                j -= srcm->m_len;
@@ -1619,7 +1619,7 @@
        slen = srcm->m_len - j;
 
        j = offset;
-       while (j >= 0) {
+       while (1) {
                if (dstm->m_len > j)
                        break;
                j -= dstm->m_len;


>Release-Note:
>Audit-Trail:

From: hiren panchasara <hiren.panchasara@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org
Cc:  
Subject: Re: kern/177155: [patch] Fixing clang warnings at /sys/dev/safe
Date: Thu, 21 Mar 2013 09:58:56 -0700

 On Wed, Mar 20, 2013 at 1:10 PM,  <FreeBSD-gnats-submit@freebsd.org> wrote:
 > Thank you very much for your problem report.
 > It has the internal identification `kern/177155'.
 > The individual assigned to look at your
 > report is: freebsd-bugs.
 >
 > You can access the state of your problem report at any time
 > via this link:
 >
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=177155
 >
 >>Category:       kern
 >>Responsible:    freebsd-bugs
 >>Synopsis:       [patch] Fixing clang warnings at /sys/dev/safe
 >>Arrival-Date:   Wed Mar 20 20:10:00 UTC 2013
 
 Taking a closer look, more correct fix looks like this:
 
 Index: sys/dev/safe/safe.c
 ===================================================================
 --- sys/dev/safe/safe.c (revision 248555)
 +++ sys/dev/safe/safe.c (working copy)
 @@ -122,7 +122,7 @@
  static void safe_intr(void *);
  static void safe_callback(struct safe_softc *, struct safe_ringentry *);
  static void safe_feed(struct safe_softc *, struct safe_ringentry *);
 -static void safe_mcopy(struct mbuf *, struct mbuf *, u_int);
 +static void safe_mcopy(struct mbuf *, struct mbuf *, int);
  #ifndef SAFE_NO_RNG
  static void safe_rng_init(struct safe_softc *);
  static void safe_rng(void *);
 @@ -1598,10 +1598,11 @@
   * Copy all data past offset from srcm to dstm.
   */
  static void
 -safe_mcopy(struct mbuf *srcm, struct mbuf *dstm, u_int offset)
 +safe_mcopy(struct mbuf *srcm, struct mbuf *dstm, int offset)
  {
 -       u_int j, dlen, slen;
 +       u_int dlen, slen;
         caddr_t dptr, sptr;
 +       int j;
 
         /*
          * Advance src and dst to offset.
 
 Reason being (as per my understanding):
 safe_mcopy() is being called from only one place: safe_process() where
 3rd arg to safe_mcopy() oplen is of type int.
 
 Thanks,
 Hiren
Responsible-Changed-From-To: freebsd-bugs->hiren 
Responsible-Changed-By: hiren 
Responsible-Changed-When: Mon Apr 15 06:12:48 UTC 2013 
Responsible-Changed-Why:  
Grabbing the PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=177155 
>Unformatted:
