aboutsummaryrefslogtreecommitdiff
path: root/nptl_db
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2024-11-16 16:51:31 +0100
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-11-25 16:45:59 -0300
commit53fcdf5f743aa9b02972eec658e66f96d6a63386 (patch)
treee1bd3ed90d89027abe4b8ba6f0dbffd833f08a9b /nptl_db
parent83d4b42ded712bbbc22ceeefe886b8315190da5b (diff)
downloadglibc-53fcdf5f743aa9b02972eec658e66f96d6a63386.tar.xz
glibc-53fcdf5f743aa9b02972eec658e66f96d6a63386.zip
Silence most -Wzero-as-null-pointer-constant diagnostics
Replace 0 by NULL and {0} by {}. Omit a few cases that aren't so trivial to fix. Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117059> Link: <https://software.codidact.com/posts/292718/292759#answer-292759> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'nptl_db')
-rw-r--r--nptl_db/fetch-value.c2
-rw-r--r--nptl_db/td_init.c2
-rw-r--r--nptl_db/td_ta_clear_event.c2
-rw-r--r--nptl_db/td_ta_event_getmsg.c6
-rw-r--r--nptl_db/td_ta_map_lwp2thr.c8
-rw-r--r--nptl_db/td_ta_set_event.c2
-rw-r--r--nptl_db/td_ta_thr_iter.c10
-rw-r--r--nptl_db/td_ta_tsd_iter.c2
-rw-r--r--nptl_db/td_thr_event_enable.c2
-rw-r--r--nptl_db/td_thr_event_getmsg.c6
-rw-r--r--nptl_db/td_thr_get_info.c16
-rw-r--r--nptl_db/td_thr_getfpregs.c2
-rw-r--r--nptl_db/td_thr_getgregs.c2
-rw-r--r--nptl_db/td_thr_setfpregs.c2
-rw-r--r--nptl_db/td_thr_setgregs.c2
-rw-r--r--nptl_db/td_thr_tlsbase.c10
-rw-r--r--nptl_db/td_thr_tsd.c6
-rw-r--r--nptl_db/td_thr_validate.c10
-rw-r--r--nptl_db/thread_dbP.h6
19 files changed, 49 insertions, 49 deletions
diff --git a/nptl_db/fetch-value.c b/nptl_db/fetch-value.c
index bdf1f444d6..5d7474b18d 100644
--- a/nptl_db/fetch-value.c
+++ b/nptl_db/fetch-value.c
@@ -69,7 +69,7 @@ _td_locate_field (td_thragent_t *ta,
}
}
- if (idx != 0 && DB_DESC_NELEM (desc) != 0
+ if (idx != NULL && DB_DESC_NELEM (desc) != 0
&& idx - (psaddr_t) 0 > DB_DESC_NELEM (desc))
/* This is an internal indicator to callers with nonzero IDX
that the IDX value is too big. */
diff --git a/nptl_db/td_init.c b/nptl_db/td_init.c
index f47b68d92c..b431ea6360 100644
--- a/nptl_db/td_init.c
+++ b/nptl_db/td_init.c
@@ -32,7 +32,7 @@ td_init (void)
bool
__td_ta_rtld_global (td_thragent_t *ta)
{
- if (ta->ta_addr__rtld_global == 0)
+ if (ta->ta_addr__rtld_global == NULL)
{
psaddr_t rtldglobalp;
if (DB_GET_VALUE (rtldglobalp, ta, __nptl_rtld_global, 0) == TD_OK)
diff --git a/nptl_db/td_ta_clear_event.c b/nptl_db/td_ta_clear_event.c
index ebba4e83dc..6322d800af 100644
--- a/nptl_db/td_ta_clear_event.c
+++ b/nptl_db/td_ta_clear_event.c
@@ -25,7 +25,7 @@ td_ta_clear_event (const td_thragent_t *ta_arg, td_thr_events_t *event)
{
td_thragent_t *const ta = (td_thragent_t *) ta_arg;
td_err_e err;
- psaddr_t eventmask = 0;
+ psaddr_t eventmask = NULL;
void *copy = NULL;
LOG ("td_ta_clear_event");
diff --git a/nptl_db/td_ta_event_getmsg.c b/nptl_db/td_ta_event_getmsg.c
index 8598716c74..d199546f59 100644
--- a/nptl_db/td_ta_event_getmsg.c
+++ b/nptl_db/td_ta_event_getmsg.c
@@ -46,7 +46,7 @@ td_ta_event_getmsg (const td_thragent_t *ta_arg, td_event_msg_t *msg)
if (err != TD_OK)
return err;
- if (thp == 0)
+ if (thp == NULL)
/* Nothing waiting. */
return TD_NOMSG;
@@ -95,9 +95,9 @@ td_ta_event_getmsg (const td_thragent_t *ta_arg, td_event_msg_t *msg)
if (err != TD_OK)
return err;
- if (next != 0)
+ if (next != NULL)
/* Clear the next pointer in the current descriptor. */
- err = DB_PUT_FIELD (ta, thp, pthread, nextevent, 0, 0);
+ err = DB_PUT_FIELD (ta, thp, pthread, nextevent, 0, NULL);
return err;
}
diff --git a/nptl_db/td_ta_map_lwp2thr.c b/nptl_db/td_ta_map_lwp2thr.c
index 1bd1fe9ec7..ab16e40119 100644
--- a/nptl_db/td_ta_map_lwp2thr.c
+++ b/nptl_db/td_ta_map_lwp2thr.c
@@ -119,7 +119,7 @@ __td_ta_lookup_th_unique (const td_thragent_t *ta_arg,
if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
return TD_ERR;
terr = _td_fetch_value_local (ta, ta->ta_howto_data.reg, -1,
- 0, regs, &addr);
+ NULL, regs, &addr);
if (terr != TD_OK)
return terr;
@@ -149,7 +149,7 @@ __td_ta_lookup_th_unique (const td_thragent_t *ta_arg,
if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
return TD_ERR;
terr = _td_fetch_value_local (ta, ta->ta_howto_data.reg_thread_area,
- -1, 0, regs, &addr);
+ -1, NULL, regs, &addr);
if (terr != TD_OK)
return terr;
/* In this descriptor the nelem word is overloaded as scale factor. */
@@ -195,12 +195,12 @@ td_ta_map_lwp2thr (const td_thragent_t *ta_arg,
if (err != TD_OK)
return err;
- if (list == 0)
+ if (list == NULL)
{
if (ps_getpid (ta->ph) != lwpid)
return TD_ERR;
th->th_ta_p = ta;
- th->th_unique = 0;
+ th->th_unique = NULL;
return TD_OK;
}
diff --git a/nptl_db/td_ta_set_event.c b/nptl_db/td_ta_set_event.c
index ee674b35fc..ee3d63e4e6 100644
--- a/nptl_db/td_ta_set_event.c
+++ b/nptl_db/td_ta_set_event.c
@@ -25,7 +25,7 @@ td_ta_set_event (const td_thragent_t *ta_arg, td_thr_events_t *event)
{
td_thragent_t *const ta = (td_thragent_t *) ta_arg;
td_err_e err;
- psaddr_t eventmask = 0;
+ psaddr_t eventmask = NULL;
void *copy = NULL;
LOG ("td_ta_set_event");
diff --git a/nptl_db/td_ta_thr_iter.c b/nptl_db/td_ta_thr_iter.c
index ce0c06cb3a..cb3d8abb61 100644
--- a/nptl_db/td_ta_thr_iter.c
+++ b/nptl_db/td_ta_thr_iter.c
@@ -37,19 +37,19 @@ iterate_thread_list (td_thragent_t *ta, td_thr_iter_f *callback,
if (err != TD_OK)
return err;
- if (next == 0 && fake_empty)
+ if (next == NULL && fake_empty)
{
/* __pthread_initialize_minimal has not run. There is just the main
thread to return. We cannot rely on its thread register. They
sometimes contain garbage that would confuse us, left by the
kernel at exec. So if it looks like initialization is incomplete,
we only fake a special descriptor for the initial thread. */
- td_thrhandle_t th = { ta, 0 };
+ td_thrhandle_t th = { ta, NULL };
return callback (&th, cbdata_p) != 0 ? TD_DBERR : TD_OK;
}
/* Cache the offset from struct pthread to its list_t member. */
- err = DB_GET_FIELD_ADDRESS (ofs, ta, 0, pthread, list, 0);
+ err = DB_GET_FIELD_ADDRESS (ofs, ta, NULL, pthread, list, 0);
if (err != TD_OK)
return err;
@@ -66,7 +66,7 @@ iterate_thread_list (td_thragent_t *ta, td_thr_iter_f *callback,
psaddr_t addr, schedpolicy, schedprio;
addr = next - (ofs - (psaddr_t) 0);
- if (next == 0 || addr == 0) /* Sanity check. */
+ if (next == NULL || addr == NULL) /* Sanity check. */
return TD_DBERR;
/* Copy the whole descriptor in once so we can access the several
@@ -117,7 +117,7 @@ td_ta_thr_iter (const td_thragent_t *ta_arg, td_thr_iter_f *callback,
{
td_thragent_t *const ta = (td_thragent_t *) ta_arg;
td_err_e err;
- psaddr_t list = 0;
+ psaddr_t list = NULL;
LOG ("td_ta_thr_iter");
diff --git a/nptl_db/td_ta_tsd_iter.c b/nptl_db/td_ta_tsd_iter.c
index 58d68eb871..592d43ecc2 100644
--- a/nptl_db/td_ta_tsd_iter.c
+++ b/nptl_db/td_ta_tsd_iter.c
@@ -38,7 +38,7 @@ td_ta_tsd_iter (const td_thragent_t *ta_arg, td_key_iter_f *callback,
return TD_BADTA;
/* This makes sure we have the size information on hand. */
- addr = 0;
+ addr = NULL;
err = _td_locate_field (ta,
ta->ta_var___pthread_keys, SYM_DESC___pthread_keys,
(psaddr_t) 0 + 1, &addr);
diff --git a/nptl_db/td_thr_event_enable.c b/nptl_db/td_thr_event_enable.c
index 48c474c667..c630722a88 100644
--- a/nptl_db/td_thr_event_enable.c
+++ b/nptl_db/td_thr_event_enable.c
@@ -24,7 +24,7 @@ td_thr_event_enable (const td_thrhandle_t *th, int onoff)
{
LOG ("td_thr_event_enable");
- if (th->th_unique != 0)
+ if (th->th_unique != NULL)
{
/* Write the new value into the thread data structure. */
td_err_e err = DB_PUT_FIELD (th->th_ta_p, th->th_unique, pthread,
diff --git a/nptl_db/td_thr_event_getmsg.c b/nptl_db/td_thr_event_getmsg.c
index c0db52dd62..aa5f552891 100644
--- a/nptl_db/td_thr_event_getmsg.c
+++ b/nptl_db/td_thr_event_getmsg.c
@@ -74,7 +74,7 @@ td_thr_event_getmsg (const td_thrhandle_t *th, td_event_msg_t *msg)
if (err != TD_OK)
return err;
- while (thp != 0)
+ while (thp != NULL)
{
psaddr_t next;
err = DB_GET_FIELD (next, th->th_ta_p, th->th_unique, pthread,
@@ -97,13 +97,13 @@ td_thr_event_getmsg (const td_thrhandle_t *th, td_event_msg_t *msg)
err = _td_store_value (th->th_ta_p,
th->th_ta_p->ta_var___nptl_last_event, -1,
- 0, prevp, next);
+ NULL, prevp, next);
if (err != TD_OK)
return err;
/* Now clear this thread's own next pointer so it's not dangling
when the thread resumes and then chains on for its next event. */
- return DB_PUT_FIELD (th->th_ta_p, thp, pthread, nextevent, 0, 0);
+ return DB_PUT_FIELD (th->th_ta_p, thp, pthread, nextevent, 0, NULL);
}
err = DB_GET_FIELD_ADDRESS (prevp, th->th_ta_p, thp, pthread,
diff --git a/nptl_db/td_thr_get_info.c b/nptl_db/td_thr_get_info.c
index 84765d7c91..6584a69257 100644
--- a/nptl_db/td_thr_get_info.c
+++ b/nptl_db/td_thr_get_info.c
@@ -31,21 +31,21 @@ td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop)
LOG ("td_thr_get_info");
- if (th->th_unique == 0)
+ if (th->th_unique == NULL)
{
/* Special case for the main thread before initialization. */
copy = NULL;
- tls = 0;
- cancelhandling = 0;
+ tls = NULL;
+ cancelhandling = NULL;
schedpolicy = SCHED_OTHER;
- schedprio = 0;
- tid = 0;
+ schedprio = NULL;
+ tid = NULL;
/* Ignore errors to obtain the __nptl_initial_report_events
value because GDB no longer uses the events interface, and
other libthread_db consumers hopefully can handle different
libpthread/lds.o load orders. */
- report_events = 0;
+ report_events = NULL;
(void) DB_GET_VALUE (report_events, th->th_ta_p,
__nptl_initial_report_events, 0);
err = TD_OK;
@@ -105,8 +105,8 @@ td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop)
/* Initialization which are the same in both cases. */
infop->ti_ta_p = th->th_ta_p;
- infop->ti_lid = tid == 0 ? ps_getpid (th->th_ta_p->ph) : (uintptr_t) tid;
- infop->ti_traceme = report_events != 0;
+ infop->ti_lid = tid == NULL ? ps_getpid (th->th_ta_p->ph) : (uintptr_t) tid;
+ infop->ti_traceme = report_events != NULL;
if (copy != NULL)
err = DB_GET_FIELD_LOCAL (infop->ti_startfunc, th->th_ta_p, copy, pthread,
diff --git a/nptl_db/td_thr_getfpregs.c b/nptl_db/td_thr_getfpregs.c
index 81bbcdffb6..0af1e44331 100644
--- a/nptl_db/td_thr_getfpregs.c
+++ b/nptl_db/td_thr_getfpregs.c
@@ -27,7 +27,7 @@ td_thr_getfpregs (const td_thrhandle_t *th, prfpregset_t *regset)
LOG ("td_thr_getfpregs");
- if (th->th_unique == 0)
+ if (th->th_unique == NULL)
/* Special case for the main thread before initialization. */
return ps_lgetfpregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph),
regset) != PS_OK ? TD_ERR : TD_OK;
diff --git a/nptl_db/td_thr_getgregs.c b/nptl_db/td_thr_getgregs.c
index eb075473aa..1dc0ec7063 100644
--- a/nptl_db/td_thr_getgregs.c
+++ b/nptl_db/td_thr_getgregs.c
@@ -27,7 +27,7 @@ td_thr_getgregs (const td_thrhandle_t *th, prgregset_t regset)
LOG ("td_thr_getgregs");
- if (th->th_unique == 0)
+ if (th->th_unique == NULL)
/* Special case for the main thread before initialization. */
return ps_lgetregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph),
regset) != PS_OK ? TD_ERR : TD_OK;
diff --git a/nptl_db/td_thr_setfpregs.c b/nptl_db/td_thr_setfpregs.c
index dae133464c..11b2fa814f 100644
--- a/nptl_db/td_thr_setfpregs.c
+++ b/nptl_db/td_thr_setfpregs.c
@@ -27,7 +27,7 @@ td_thr_setfpregs (const td_thrhandle_t *th, const prfpregset_t *fpregs)
LOG ("td_thr_setfpregs");
- if (th->th_unique == 0)
+ if (th->th_unique == NULL)
/* Special case for the main thread before initialization. */
return ps_lsetfpregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph),
fpregs) != PS_OK ? TD_ERR : TD_OK;
diff --git a/nptl_db/td_thr_setgregs.c b/nptl_db/td_thr_setgregs.c
index aa51885fd3..9f6c3a3547 100644
--- a/nptl_db/td_thr_setgregs.c
+++ b/nptl_db/td_thr_setgregs.c
@@ -27,7 +27,7 @@ td_thr_setgregs (const td_thrhandle_t *th, prgregset_t gregs)
LOG ("td_thr_setgregs");
- if (th->th_unique == 0)
+ if (th->th_unique == NULL)
/* Special case for the main thread before initialization. */
return ps_lsetregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph),
gregs) != PS_OK ? TD_ERR : TD_OK;
diff --git a/nptl_db/td_thr_tlsbase.c b/nptl_db/td_thr_tlsbase.c
index a952eea798..9a3f59aa80 100644
--- a/nptl_db/td_thr_tlsbase.c
+++ b/nptl_db/td_thr_tlsbase.c
@@ -37,14 +37,14 @@ dtv_slotinfo_list (td_thragent_t *ta,
}
else
{
- if (ta->ta_addr__dl_tls_dtv_slotinfo_list == 0
+ if (ta->ta_addr__dl_tls_dtv_slotinfo_list == NULL
&& td_mod_lookup (ta->ph, NULL, SYM__dl_tls_dtv_slotinfo_list,
&ta->ta_addr__dl_tls_dtv_slotinfo_list) != PS_OK)
return TD_ERR;
err = _td_fetch_value (ta, ta->ta_var__dl_tls_dtv_slotinfo_list,
- SYM_DESC__dl_tls_dtv_slotinfo_list,
- 0, ta->ta_addr__dl_tls_dtv_slotinfo_list, &head);
+ SYM_DESC__dl_tls_dtv_slotinfo_list, NULL,
+ ta->ta_addr__dl_tls_dtv_slotinfo_list, &head);
if (err != TD_OK)
return err;
}
@@ -129,7 +129,7 @@ td_thr_tlsbase (const td_thrhandle_t *th,
return TD_NOTLS;
psaddr_t pd = th->th_unique;
- if (pd == 0)
+ if (pd == NULL)
{
/* This is the fake handle for the main thread before libpthread
initialization. We are using 0 for its th_unique because we can't
@@ -145,7 +145,7 @@ td_thr_tlsbase (const td_thrhandle_t *th,
&main_th);
if (err == 0)
pd = main_th.th_unique;
- if (pd == 0)
+ if (pd == NULL)
return TD_TLSDEFER;
}
diff --git a/nptl_db/td_thr_tsd.c b/nptl_db/td_thr_tsd.c
index 234e894dbb..19dc2e7749 100644
--- a/nptl_db/td_thr_tsd.c
+++ b/nptl_db/td_thr_tsd.c
@@ -42,8 +42,8 @@ td_thr_tsd (const td_thrhandle_t *th, const thread_key_t tk, void **data)
return TD_BADKEY;
/* This makes sure we have the size information on hand. */
- err = DB_GET_FIELD_ADDRESS (level2, th->th_ta_p, 0, pthread_key_data_level2,
- data, 1);
+ err = DB_GET_FIELD_ADDRESS (level2, th->th_ta_p, NULL,
+ pthread_key_data_level2, data, 1);
if (err != TD_OK)
return err;
@@ -62,7 +62,7 @@ td_thr_tsd (const td_thrhandle_t *th, const thread_key_t tk, void **data)
return err;
/* Check the pointer to the second level array. */
- if (level1 == 0)
+ if (level1 == NULL)
return TD_NOTSD;
/* Locate the element within the second level array. */
diff --git a/nptl_db/td_thr_validate.c b/nptl_db/td_thr_validate.c
index 0c3afe346f..76c4cf547b 100644
--- a/nptl_db/td_thr_validate.c
+++ b/nptl_db/td_thr_validate.c
@@ -27,7 +27,7 @@ __td_ta_stack_user (td_thragent_t *ta, psaddr_t *plist)
rtld_global, _dl_stack_user, 0);
else
{
- if (ta->ta_addr__dl_stack_user == 0
+ if (ta->ta_addr__dl_stack_user == NULL
&& td_mod_lookup (ta->ph, NULL, SYM__dl_stack_user,
&ta->ta_addr__dl_stack_user) != PS_OK)
return TD_ERR;
@@ -45,7 +45,7 @@ __td_ta_stack_used (td_thragent_t *ta, psaddr_t *plist)
rtld_global, _dl_stack_used, 0);
else
{
- if (ta->ta_addr__dl_stack_used == 0
+ if (ta->ta_addr__dl_stack_used == NULL
&& td_mod_lookup (ta->ph, NULL, SYM__dl_stack_used,
&ta->ta_addr__dl_stack_used) != PS_OK)
return TD_ERR;
@@ -63,12 +63,12 @@ check_thread_list (const td_thrhandle_t *th, psaddr_t head, bool *uninit)
err = DB_GET_FIELD (next, th->th_ta_p, head, list_t, next, 0);
if (err == TD_OK)
{
- if (next == 0)
+ if (next == NULL)
{
*uninit = true;
return TD_NOTHR;
}
- err = DB_GET_FIELD_ADDRESS (ofs, th->th_ta_p, 0, pthread, list, 0);
+ err = DB_GET_FIELD_ADDRESS (ofs, th->th_ta_p, NULL, pthread, list, 0);
}
while (err == TD_OK)
@@ -108,7 +108,7 @@ td_thr_validate (const td_thrhandle_t *th)
if (err == TD_OK)
err = check_thread_list (th, list, &uninit);
- if (err == TD_NOTHR && uninit && th->th_unique == 0)
+ if (err == TD_NOTHR && uninit && th->th_unique == NULL)
/* __pthread_initialize_minimal has not run yet.
There is only the special case thread handle. */
err = TD_OK;
diff --git a/nptl_db/thread_dbP.h b/nptl_db/thread_dbP.h
index 72d5558845..24960d048e 100644
--- a/nptl_db/thread_dbP.h
+++ b/nptl_db/thread_dbP.h
@@ -158,7 +158,7 @@ extern ps_err_e td_mod_lookup (struct ps_prochandle *ps, const char *modname,
/* Store in psaddr_t VAR the address of inferior's symbol NAME. */
#define DB_GET_SYMBOL(var, ta, name) \
- (((ta)->ta_addr_##name == 0 \
+ (((ta)->ta_addr_##name == NULL \
&& td_lookup ((ta)->ph, SYM_##name, &(ta)->ta_addr_##name) != PS_OK) \
? TD_ERR : ((var) = (ta)->ta_addr_##name, TD_OK))
@@ -199,7 +199,7 @@ extern td_err_e _td_locate_field (td_thragent_t *ta,
/* Store in psaddr_t VAR the value of variable NAME[IDX] in the inferior.
A target value smaller than psaddr_t is zero-extended. */
#define DB_GET_VALUE(var, ta, name, idx) \
- (((ta)->ta_addr_##name == 0 \
+ (((ta)->ta_addr_##name == NULL \
&& td_lookup ((ta)->ph, SYM_##name, &(ta)->ta_addr_##name) != PS_OK) \
? TD_ERR \
: _td_fetch_value ((ta), (ta)->ta_var_##name, SYM_DESC_##name, \
@@ -231,7 +231,7 @@ extern td_err_e _td_fetch_value_local (td_thragent_t *ta,
/* Store psaddr_t VALUE in variable NAME[IDX] in the inferior.
A target field smaller than psaddr_t is zero-extended. */
#define DB_PUT_VALUE(ta, name, idx, value) \
- (((ta)->ta_addr_##name == 0 \
+ (((ta)->ta_addr_##name == NULL \
&& td_lookup ((ta)->ph, SYM_##name, &(ta)->ta_addr_##name) != PS_OK) \
? TD_ERR \
: _td_store_value ((ta), (ta)->ta_var_##name, SYM_DESC_##name, \