libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [PATCH 53/57] Prefer NULL over zero


From: Tommi Rantala
Subject: [Libunwind-devel] [PATCH 53/57] Prefer NULL over zero
Date: Fri, 21 Sep 2012 14:11:54 +0300

---
 include/libunwind_i.h           |   10 +++++-----
 src/dwarf/Gfind_proc_info-lsb.c |    2 +-
 src/dwarf/Gparser.c             |    6 +++---
 src/mips/Ginit.c                |    2 +-
 src/os-linux.h                  |    4 ++--
 src/x86_64/Ginit.c              |    2 +-
 src/x86_64/Ginit_remote.c       |    2 +-
 src/x86_64/Gtrace.c             |    6 +++---
 tests/mapper.c                  |    2 +-
 tests/test-ptrace.c             |    2 +-
 10 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/include/libunwind_i.h b/include/libunwind_i.h
index f7e3204..0c56c21 100644
--- a/include/libunwind_i.h
+++ b/include/libunwind_i.h
@@ -88,11 +88,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.  */
 #pragma weak pthread_mutex_unlock
 
 #define mutex_init(l)                                                  \
-       (pthread_mutex_init != 0 ? pthread_mutex_init ((l), 0) : 0)
+       (pthread_mutex_init != NULL ? pthread_mutex_init ((l), NULL) : 0)
 #define mutex_lock(l)                                                  \
-       (pthread_mutex_lock != 0 ? pthread_mutex_lock (l) : 0)
+       (pthread_mutex_lock != NULL ? pthread_mutex_lock (l) : 0)
 #define mutex_unlock(l)                                                        
\
-       (pthread_mutex_unlock != 0 ? pthread_mutex_unlock (l) : 0)
+       (pthread_mutex_unlock != NULL ? pthread_mutex_unlock (l) : 0)
 
 #ifdef HAVE_ATOMIC_OPS_H
 # include <atomic_ops.h>
@@ -156,8 +156,8 @@ do {                                                \
 #define GET_MEMORY(mem, size)                                              \
 do {                                                                       \
   /* Hopefully, mmap() goes straight through to a system call stub...  */   \
-  mem = mmap (0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, \
-             -1, 0);                                                       \
+  mem = mmap (NULL, size, PROT_READ | PROT_WRITE,                          \
+             MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);                          \
   if (mem == MAP_FAILED)                                                   \
     mem = NULL;                                                                
    \
 } while (0)
diff --git a/src/dwarf/Gfind_proc_info-lsb.c b/src/dwarf/Gfind_proc_info-lsb.c
index ae0b939..975c969 100644
--- a/src/dwarf/Gfind_proc_info-lsb.c
+++ b/src/dwarf/Gfind_proc_info-lsb.c
@@ -757,7 +757,7 @@ static inline const struct table_entry *
 lookup (const struct table_entry *table, size_t table_size, int32_t rel_ip)
 {
   unsigned long table_len = table_size / sizeof (struct table_entry);
-  const struct table_entry *e = 0;
+  const struct table_entry *e = NULL;
   unsigned long lo, hi, mid;
 
   /* do a binary search for right entry: */
diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c
index fd2bdae..49c79db 100644
--- a/src/dwarf/Gparser.c
+++ b/src/dwarf/Gparser.c
@@ -582,7 +582,7 @@ rs_lookup (struct dwarf_rs_cache *cache, struct 
dwarf_cursor *c)
 
   index = cache->hash[hash (ip)];
   if (index >= DWARF_UNW_CACHE_SIZE)
-    return 0;
+    return NULL;
 
   rs = cache->buckets + index;
   while (1)
@@ -595,7 +595,7 @@ rs_lookup (struct dwarf_rs_cache *cache, struct 
dwarf_cursor *c)
           return rs;
         }
       if (rs->coll_chain >= DWARF_UNW_HASH_SIZE)
-        return 0;
+        return NULL;
       rs = cache->buckets + rs->coll_chain;
     }
 }
@@ -620,7 +620,7 @@ rs_new (struct dwarf_rs_cache *cache, struct dwarf_cursor * 
c)
     {
       index = hash (rs->ip);
       tmp = cache->buckets + cache->hash[index];
-      prev = 0;
+      prev = NULL;
       while (1)
        {
          if (tmp == rs)
diff --git a/src/mips/Ginit.c b/src/mips/Ginit.c
index 31000b3..dc9c125 100644
--- a/src/mips/Ginit.c
+++ b/src/mips/Ginit.c
@@ -202,7 +202,7 @@ mips_local_addr_space_init (void)
   local_addr_space.acc.access_mem = access_mem;
   local_addr_space.acc.access_reg = access_reg;
   local_addr_space.acc.access_fpreg = access_fpreg;
-  local_addr_space.acc.resume = 0;  /* mips_local_resume?  FIXME!  */
+  local_addr_space.acc.resume = NULL;  /* mips_local_resume?  FIXME!  */
   local_addr_space.acc.get_proc_name = get_static_proc_name;
   unw_flush_cache (&local_addr_space, 0, 0);
 }
diff --git a/src/os-linux.h b/src/os-linux.h
index 5b7295b..ad9d675 100644
--- a/src/os-linux.h
+++ b/src/os-linux.h
@@ -77,7 +77,7 @@ maps_init (struct map_iterator *mi, pid_t pid)
     {
       /* Try to allocate a page-sized buffer.  */
       mi->buf_size = getpagesize ();
-      cp = mmap (0, mi->buf_size, PROT_READ | PROT_WRITE,
+      cp = mmap (NULL, mi->buf_size, PROT_READ | PROT_WRITE,
                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
       if (cp == MAP_FAILED)
        {
@@ -290,7 +290,7 @@ maps_close (struct map_iterator *mi)
   if (mi->buf)
     {
       munmap (mi->buf_end - mi->buf_size, mi->buf_size);
-      mi->buf = mi->buf_end = 0;
+      mi->buf = mi->buf_end = NULL;
     }
 }
 
diff --git a/src/x86_64/Ginit.c b/src/x86_64/Ginit.c
index ee62d02..daea078 100644
--- a/src/x86_64/Ginit.c
+++ b/src/x86_64/Ginit.c
@@ -167,7 +167,7 @@ access_mem (unw_addr_space_t as, unw_word_t addr, 
unw_word_t *val, int write,
     {
       /* validate address */
       const struct cursor *c = (const struct cursor *)arg;
-      if (likely (c != 0) && unlikely (c->validate)
+      if (likely (c != NULL) && unlikely (c->validate)
           && unlikely (validate_mem (addr)))
         return -1;
       *val = *(unw_word_t *) addr;
diff --git a/src/x86_64/Ginit_remote.c b/src/x86_64/Ginit_remote.c
index 1b7123c..4fd2092 100644
--- a/src/x86_64/Ginit_remote.c
+++ b/src/x86_64/Ginit_remote.c
@@ -50,7 +50,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, 
void *as_arg)
   else
     {
       c->dwarf.as_arg = as_arg;
-      c->uc = 0;
+      c->uc = NULL;
     }
   return common_init (c, 0);
 #endif /* !UNW_LOCAL_ONLY */
diff --git a/src/x86_64/Gtrace.c b/src/x86_64/Gtrace.c
index 89453a8..9a86a06 100644
--- a/src/x86_64/Gtrace.c
+++ b/src/x86_64/Gtrace.c
@@ -89,7 +89,7 @@ trace_cache_buckets (size_t n)
   size_t i;
 
   GET_MEMORY(frames, n * sizeof (unw_tdep_frame_t));
-  if (likely(frames != 0))
+  if (likely(frames != NULL))
     for (i = 0; i < n; ++i)
       frames[i] = empty_frame;
 
@@ -162,7 +162,7 @@ trace_cache_get_unthreaded (void)
 {
   unw_trace_cache_t *cache;
   intrmask_t saved_mask;
-  static unw_trace_cache_t *global_cache = 0;
+  static unw_trace_cache_t *global_cache = NULL;
   lock_acquire (&trace_init_lock, saved_mask);
   if (! global_cache)
   {
@@ -180,7 +180,7 @@ static unw_trace_cache_t *
 trace_cache_get (void)
 {
   unw_trace_cache_t *cache;
-  if (likely (pthread_once != 0))
+  if (likely (pthread_once != NULL))
   {
     pthread_once(&trace_cache_once, &trace_cache_init_once);
     if (!trace_cache_once_happen)
diff --git a/tests/mapper.c b/tests/mapper.c
index e84697b..905f319 100644
--- a/tests/mapper.c
+++ b/tests/mapper.c
@@ -51,7 +51,7 @@ main (void)
   printf ("Starting mmap test...\n");
   for (n = 0; n < 30000; ++n)
     {
-      if (mmap (0, 1, (n & 1) ? PROT_READ : PROT_WRITE,
+      if (mmap (NULL, 1, (n & 1) ? PROT_READ : PROT_WRITE,
                MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE,
                -1, 0) == MAP_FAILED)
        {
diff --git a/tests/test-ptrace.c b/tests/test-ptrace.c
index aecb06e..8b35ae6 100644
--- a/tests/test-ptrace.c
+++ b/tests/test-ptrace.c
@@ -237,7 +237,7 @@ main (int argc, char **argv)
 
   while (nerrors <= nerrors_max)
     {
-      pid = wait4 (-1, &status,  0, 0);
+      pid = wait4 (-1, &status, 0, NULL);
       if (pid == -1)
        {
          if (errno == EINTR)
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]