Revision: 76785
          http://sourceforge.net/p/brlcad/code/76785
Author:   brlcad
Date:     2020-08-15 14:06:46 +0000 (Sat, 15 Aug 2020)
Log Message:
-----------
document the checks being used by BU_CKMAG since they're fairly low-level 
operations.  add a direct check for nullity, too.  will have to keep an eye on 
whether the null check provokes an unreachable expression warning on linters 
(e.g., coverity).  shouldn't be redundant on a platform with non-zero valued 
null pointers.

Modified Paths:
--------------
    brlcad/trunk/include/bu/magic.h

Modified: brlcad/trunk/include/bu/magic.h
===================================================================
--- brlcad/trunk/include/bu/magic.h     2020-08-15 14:06:45 UTC (rev 76784)
+++ brlcad/trunk/include/bu/magic.h     2020-08-15 14:06:46 UTC (rev 76785)
@@ -241,7 +241,11 @@
 #  define BU_CKMAG(_ptr, _magic, _str) (void)(_ptr)
 #else
 #  define BU_CKMAG(_ptr, _magic, _str) do { \
-       if (UNLIKELY(((uintptr_t)(_ptr) == 0) || ((uintptr_t)(_ptr) & 
(sizeof((uintptr_t)(_ptr))-1)) || *((const uint32_t *)(_ptr)) != 
(uint32_t)(_magic))) { \
+    if (UNLIKELY(( (!(_ptr)) /* non-NULL pointer */ \
+                  || ((uintptr_t)(_ptr) == 0) /* non-zero pointer */ \
+                  || ((uintptr_t)(_ptr) & (sizeof((uintptr_t)(_ptr))-1)) /* 
aligned ptr */ \
+                  || (*((const uint32_t *)(_ptr)) != (uint32_t)(_magic)) /* 
matches value */ \
+                    ))) { \
            bu_badmagic((const uint32_t *)(_ptr), (uint32_t)(_magic), _str, 
__FILE__, __LINE__); \
        } \
     } while (0)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to