struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
str = sock_decode_type(ux->type);
- return strdup(str);
+ return xstrdup(str);
}
static char *unix_get_state(struct sock_xinfo *sock_xinfo,
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
if (ux->acceptcon)
- return strdup("listen");
+ return xstrdup("listen");
str = unix_decode_state(ux->st);
- return strdup(str);
+ return xstrdup(str);
}
static bool unix_get_listening(struct sock_xinfo *sock_xinfo,
switch (column_id) {
case COL_UNIX_PATH:
if (*ux->path) {
- *str = strdup(ux->path);
+ *str = xstrdup(ux->path);
return true;
}
break;
} \
\
if (n && inet_ntop(class->family, n, s, sizeof(s))) { \
- *STR = strdup(s); \
+ *STR = xstrdup(s); \
r = true; \
} \
r; \
static char *tcp_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
- return strdup("stream");
+ return xstrdup("stream");
}
static char *tcp_get_state(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
- return strdup(l4_decode_state(((struct l4_xinfo *)sock_xinfo)->st));
+ return xstrdup(l4_decode_state(((struct l4_xinfo *)sock_xinfo)->st));
}
static bool tcp_get_listening(struct sock_xinfo *sock_xinfo,
static char *udp_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
- return strdup("dgram");
+ return xstrdup("dgram");
}
static bool udp_fill_column(struct proc *proc __attribute__((__unused__)),
static char *raw_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
- return strdup("raw");
+ return xstrdup("raw");
}
static bool raw_fill_column(struct proc *proc __attribute__((__unused__)),
static char *ping_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
- return strdup("dgram");
+ return xstrdup("dgram");
}
static bool ping_fill_column(struct proc *proc __attribute__((__unused__)),
static char *netlink_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
- return strdup("raw");
+ return xstrdup("raw");
}
static bool netlink_fill_column(struct proc *proc __attribute__((__unused__)),
xasprintf(str, "%"PRIu32, nl->lportid);
return true;
case COL_NETLINK_PROTOCOL:
- *str = strdup(netlink_decode_protocol(nl->protocol));
+ *str = xstrdup(netlink_decode_protocol(nl->protocol));
return true;
}
char *name;
if (unkn->anon_ops->class)
- return strdup(unkn->anon_ops->class);
+ return xstrdup(unkn->anon_ops->class);
/* See unkn_init_content() */
name = ((struct file *)unkn)->name + 11;
return strndup(name + 1, len - 1);
}
- return strdup(name);
+ return xstrdup(name);
}
static bool unkn_fill_column(struct proc *proc,
return false;
case COL_SOURCE:
if (unkn->anon_ops) {
- str = strdup("anon_inodefs");
+ str = xstrdup("anon_inodefs");
break;
}
return false;
if (pidfd_proc)
pidfd_comm = pidfd_proc->command;
if (pidfd_comm) {
- *str = strdup(pidfd_comm);
+ *str = xstrdup(pidfd_comm);
return true;
}
break;
}
case COL_PIDFD_NSPID:
if (data->nspid) {
- *str = strdup(data->nspid);
+ *str = xstrdup(data->nspid);
return true;
}
break;
"failed to specify a buffer spec to a packet socket");
}
- munmap_data = malloc(sizeof (*munmap_data));
- if (munmap_data == NULL) {
- close(sd);
- errx(EXIT_FAILURE, "memory exhausted");
- }
+ munmap_data = xmalloc(sizeof (*munmap_data));
munmap_data->len = (size_t) req.tp_block_size * req.tp_block_nr;
munmap_data->ptr = mmap(NULL, munmap_data->len, PROT_WRITE, MAP_SHARED, sd, 0);
if (munmap_data->ptr == MAP_FAILED) {