size_t sz = 0;
int err = 0;
- if (data == NULL)
+ if (!data)
return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_ARG);
if (lseek (fd, addr, SEEK_SET) == -1)
return SFRAME_BT_OK;
}
-/* sframe_valid_addr_p - Check if ADDR is valid in CF. The address is considered
- invalid, with regards to SFrame, if it's not in any address range of the
- main module or any of its DSO's. Return 1 if valid, 0 otherwise. */
+/* Check if ADDR is valid in SF.
-static int
+ The address is considered invalid, with regards to SFrame, if it's not in
+ any address range of the main module or any of its DSO's.
+
+ Return 1 if valid, 0 otherwise. */
+
+static bool
sframe_valid_addr_p (struct sframe_state *sf, uint64_t addr)
{
struct sframe_stinfo *cdp;
- if (sf == NULL)
+ if (!sf)
return 0;
cdp = sframe_find_context (sf, addr);
RA_LST and contains the number of the addresses collected. */
static int
-sframe_unwind (struct sframe_state *sf, void **ra_lst,
- int *ra_size)
+sframe_unwind (struct sframe_state *sf, void **ra_lst, int *ra_size)
{
uint64_t cfa, return_addr, ra_stack_loc, rfp_stack_loc;
sframe_decoder_ctx *ctx;
ucontext_t context, *cp = &context;
int err = 0;
- if (sf == NULL || ra_lst == NULL || ra_size == NULL)
+ if (!sf || !ra_lst || !ra_size)
return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_ARG);
/* Get the user context for its registers. */
- if (getcontext (cp) != 0)
+ if (getcontext (cp))
return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_GETCONTEXT);
pc = get_context_pc (cp);
/* Load and set up the decoder. */
ctx = sframe_load_ctx (sf, pc);
- if (ctx == NULL)
+ if (!ctx)
return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_DECODE);
cfi_vma = sf->sui_ctx.sfdd_sframe_vma;
{
pc -= cfi_vma;
errnum = sframe_find_fre (ctx, pc, frep);
- if (errnum == 0)
+ if (!errnum)
{
cfa_offset = sframe_fre_get_cfa_offset (ctx, frep, &errnum);
if (errnum == SFRAME_ERR_FREOFFSET_NOPRESENT)
== SFRAME_BASE_REG_SP) ? rsp : rfp) + cfa_offset;
ra_offset = sframe_fre_get_ra_offset (ctx, frep, &errnum);
- if (errnum == 0)
+ if (!errnum)
{
ra_stack_loc = cfa + ra_offset;
errnum = get_contents_8b (sf->sui_fd, ra_stack_loc, &return_addr);
}
/* Validate and add return address to the list. */
- if (sframe_valid_addr_p (sf, return_addr) == 0)
+ if (!sframe_valid_addr_p (sf, return_addr))
{
i -= 1;
goto find_fre_ra_err;
/* Set up for the next frame. */
rfp_offset = sframe_fre_get_fp_offset (ctx, frep, &errnum);
- if (errnum == 0)
+ if (!errnum)
{
rfp_stack_loc = cfa + rfp_offset;
errnum = get_contents_8b (sf->sui_fd, rfp_stack_loc, &rfp);
/* Check if need to update the decoder context and vma. */
sframe_update_ctx (sf, return_addr, &ctx, &cfi_vma);
- if (ctx == NULL)
+ if (!ctx)
return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_DECODE);
}
else
/* Find the .sframe sections and setup the SFrame state for generating stack
traces. */
(void) dl_iterate_phdr (sframe_callback, (void *)&sframeinfo);
- if (sframeinfo.sui_fd == 0)
+ if (!sframeinfo.sui_fd)
{
sframe_bt_ret_set_errno (errp, SFRAME_BT_ERR_BAD_SFSTATE);
return -1;
{
int err = 0;
- if (d_list->alloced == 0)
+ if (!d_list->alloced)
{
d_list->entry = malloc (no_of_entries * sizeof (struct sframe_stinfo));
- if (d_list->entry == NULL)
+ if (!d_list->entry)
return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_MALLOC);
memset (d_list->entry, 0,
d_list->entry = realloc (d_list->entry,
((d_list->alloced + no_of_entries)
* sizeof (struct sframe_stinfo)));
- if (d_list->entry == NULL)
+ if (!d_list->entry)
return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_REALLOC);
memset (&d_list->entry[d_list->alloced], 0,
struct sframe_stinfo_list *d_list;
int i;
- if (sf == NULL)
+ if (!sf)
return;
// free (sf->sui_ctx.sfdd_data);
close (sf->sui_fd);
d_list = &sf-> sui_dsos;
- if (d_list == NULL)
+ if (!d_list)
return;
for (i = 0; i < d_list->used; ++i)
struct sframe_stinfo sdec_data;
int i;
- if (sf == NULL)
+ if (!sf)
return NULL;
if (sf->sui_ctx.sfdd_text_vma < addr
sframe_decoder_ctx *nctx;
struct sframe_stinfo *cdp;
- if (sf == NULL)
+ if (!sf)
return NULL;
cdp = sframe_find_context (sf, raddr);
- if (cdp == NULL)
+ if (!cdp)
return NULL;
- if (cdp->sfdd_sframe_ctx == NULL)
+ if (!cdp->sfdd_sframe_ctx)
{
int err;
nctx = sframe_decode (cdp->sfdd_data, cdp->sfdd_data_size, &err);
- if (nctx == NULL)
+ if (!nctx)
return NULL;
cdp->sfdd_sframe_ctx = nctx;
return nctx;
struct sframe_stinfo *cdp;
cdp = sframe_find_context (sf, raddr);
- if (cdp != NULL)
+ if (cdp)
{
- if (cdp->sfdd_sframe_ctx == NULL)
+ if (!cdp->sfdd_sframe_ctx)
{
int err;
nctx = sframe_decode (cdp->sfdd_data, cdp->sfdd_data_size, &err);
- if (nctx == NULL)
+ if (!nctx)
{
*ctx = NULL;
return;
uint64_t text_vma = 0;
int text_size = 0;
- if (data == NULL || info == NULL)
+ if (!data || !info)
return 1;
debug_printf ("-- name: %s %14p\n", info->dlpi_name, (void *)info->dlpi_addr);