Prefer NULL over zero
diff --git a/include/libunwind_i.h b/include/libunwind_i.h
index e0fb64b..23f615e 100644
--- a/include/libunwind_i.h
+++ b/include/libunwind_i.h
@@ -88,11 +88,11 @@
#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>
@@ -187,8 +187,8 @@
#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 @@
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 @@
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 @@
return rs;
}
if (rs->coll_chain >= DWARF_UNW_HASH_SIZE)
- return 0;
+ return NULL;
rs = cache->buckets + rs->coll_chain;
}
}
@@ -620,7 +620,7 @@
{
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 @@
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 @@
{
/* 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 @@
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 @@
{
/* 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 @@
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 @@
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 @@
{
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 @@
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 @@
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 69e1808..942b0db 100644
--- a/tests/test-ptrace.c
+++ b/tests/test-ptrace.c
@@ -237,7 +237,7 @@
while (nerrors <= nerrors_max)
{
- pid = wait4 (-1, &status, 0, 0);
+ pid = wait4 (-1, &status, 0, NULL);
if (pid == -1)
{
if (errno == EINTR)