On Thu, 16 Jun 2011, Bruce Evans wrote:

On Thu, 16 Jun 2011, Garrett Cooper wrote:

On Thu, Jun 16, 2011 at 12:19 AM, Garrett Cooper <yaneg...@gmail.com> wrote:
On Thu, Jun 16, 2011 at 12:14 AM, Tai-hwa Liang <ava...@freebsd.org> wrote:
Author: avatar
Date: Thu Jun 16 07:14:55 2011
New Revision: 223139
URL: http://svn.freebsd.org/changeset/base/223139

Log:
�Unbreaking build on sparc64.

Why not fix it on all arches?  This seems to break it on all 32-bit arches.

�Submitted by: Garrett Cooper <yaneg...@gmail.com>

Modified:
�head/lib/libstand/zalloc.c

Modified: head/lib/libstand/zalloc.c
==============================================================================
--- head/lib/libstand/zalloc.c �Thu Jun 16 05:26:03 2011 � � � �(r223138)
+++ head/lib/libstand/zalloc.c �Thu Jun 16 07:14:55 2011 � � � �(r223139)
@@ -154,7 +154,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t by
� � if ((char *)ptr < (char *)mp->mp_Base ||
� � � �(char *)ptr + bytes > (char *)mp->mp_End ||
� � � �((iaddr_t)ptr & MEMNODE_SIZE_MASK) != 0)
- � � � panic("zfree(%p,%d): wild pointer", ptr, bytes);
+ � � � panic("zfree(%p,%ju): wild pointer", ptr, bytes);

All of those need to be cast to (uintmax_t). Sorry :(..

Indeed.  There is no format letter for intptr_t, and perhaps iaddr_t is
supposed to be opaque anyway.

And you need to add #include <stdint.h> to stand.h in order to get
uintmax_t. Here's a proper patch for amd64..

This would add namespace pollution.  stand.h doesn't use anything in
<stdint.h>.  It depends on normal namespace pollution in an XXX section
in <sys/types.h> for the declaration of uintptr_t.  It and other headers
should use __uintptr_t instead.  Strangely, <sys/types.h> declares
uintptr_t but not uintmax_t.

  What about casting to __uintmax_t instead?

Index: zalloc.c
===================================================================
--- zalloc.c    (revision 223146)
+++ zalloc.c    (working copy)
@@ -154,7 +154,7 @@
     if ((char *)ptr < (char *)mp->mp_Base ||
        (char *)ptr + bytes > (char *)mp->mp_End ||
        ((iaddr_t)ptr & MEMNODE_SIZE_MASK) != 0)
-       panic("zfree(%p,%ju): wild pointer", ptr, bytes);
+       panic("zfree(%p,%ju): wild pointer", ptr, (__uintmax_t)bytes);

     /*
      * free the segment
@@ -177,8 +177,10 @@
                /*
                 * range check
                 */
-               if ((char *)ptr + bytes > (char *)mn)
-                   panic("zfree(%p,%ju): corrupt memlist1",ptr, bytes);
+               if ((char *)ptr + bytes > (char *)mn) {
+                   panic("zfree(%p,%ju): corrupt memlist1", ptr,
+                       (__uintmax_t)bytes);
+               }

                /*
                 * merge against next area or create independant area
@@ -208,8 +210,10 @@
                return;
                /* NOT REACHED */
            }
-           if ((char *)ptr < (char *)mn + mn->mr_Bytes)
-               panic("zfree(%p,%ju): corrupt memlist2", ptr, bytes);
+           if ((char *)ptr < (char *)mn + mn->mr_Bytes) {
+               panic("zfree(%p,%ju): corrupt memlist2", ptr,
+                   (__uintmax_t)bytes);
+           }
        }
        /*
         * We are beyond the last MemNode, append new MemNode.  Merge against
_______________________________________________
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-unsubscr...@freebsd.org"

Reply via email to