This commit improves code consistence.
Signed-off-by: Karel Zak <kzak@redhat.com>
case COL_BLKDRV:
devdrv = get_blkdrv(major(file->stat.st_rdev));
if (devdrv)
case COL_BLKDRV:
devdrv = get_blkdrv(major(file->stat.st_rdev));
if (devdrv)
else
xasprintf(&str, "%u",
major(file->stat.st_rdev));
else
xasprintf(&str, "%u",
major(file->stat.st_rdev));
case COL_PARTITION:
partition = get_partition(file->stat.st_rdev);
if (partition) {
case COL_PARTITION:
partition = get_partition(file->stat.st_rdev);
if (partition) {
- str = strdup(partition);
+ str = xstrdup(partition);
break;
}
devdrv = get_blkdrv(major(file->stat.st_rdev));
break;
}
devdrv = get_blkdrv(major(file->stat.st_rdev));
if (devdrv && strcmp(devdrv, "misc") == 0) {
miscdev = get_miscdev(minor(file->stat.st_rdev));
if (miscdev)
if (devdrv && strcmp(devdrv, "misc") == 0) {
miscdev = get_miscdev(minor(file->stat.st_rdev));
if (miscdev)
+ str = xstrdup(miscdev);
else
xasprintf(&str, "%u",
minor(file->stat.st_rdev));
else
xasprintf(&str, "%u",
minor(file->stat.st_rdev));
case COL_CHRDRV:
devdrv = get_chrdrv(major(file->stat.st_rdev));
if (devdrv)
case COL_CHRDRV:
devdrv = get_chrdrv(major(file->stat.st_rdev));
if (devdrv)
else
xasprintf(&str, "%u",
major(file->stat.st_rdev));
else
xasprintf(&str, "%u",
major(file->stat.st_rdev));
case COL_SOURCE:
if (major(file->stat.st_dev) == 0
&& strncmp(file->name, "pipe:", 5) == 0) {
case COL_SOURCE:
if (major(file->stat.st_dev) == 0
&& strncmp(file->name, "pipe:", 5) == 0) {
- str = strdup("pipefs");
+ str = xstrdup("pipefs");
case COL_PARTITION:
partition = get_partition(file->stat.st_dev);
if (partition) {
case COL_PARTITION:
partition = get_partition(file->stat.st_dev);
if (partition) {
- str = strdup(partition);
+ str = xstrdup(partition);
break;
}
/* FALL THROUGH */
break;
}
/* FALL THROUGH */
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
str = sock_decode_type(ux->type);
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
str = sock_decode_type(ux->type);
}
static char *unix_get_state(struct sock_xinfo *sock_xinfo,
}
static char *unix_get_state(struct sock_xinfo *sock_xinfo,
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
if (ux->acceptcon)
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
if (ux->acceptcon)
- return strdup("listen");
+ return xstrdup("listen");
str = unix_decode_state(ux->st);
str = unix_decode_state(ux->st);
}
static bool unix_get_listening(struct sock_xinfo *sock_xinfo,
}
static bool unix_get_listening(struct sock_xinfo *sock_xinfo,
switch (column_id) {
case COL_UNIX_PATH:
if (*ux->path) {
switch (column_id) {
case COL_UNIX_PATH:
if (*ux->path) {
- *str = strdup(ux->path);
+ *str = xstrdup(ux->path);
} \
\
if (n && inet_ntop(class->family, n, s, sizeof(s))) { \
} \
\
if (n && inet_ntop(class->family, n, s, sizeof(s))) { \
static char *tcp_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
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__)))
{
}
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 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__)))
{
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 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__)))
{
static char *raw_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
}
static bool raw_fill_column(struct proc *proc __attribute__((__unused__)),
}
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__)))
{
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 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__)))
{
static char *netlink_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
}
static bool netlink_fill_column(struct proc *proc __attribute__((__unused__)),
}
static bool netlink_fill_column(struct proc *proc __attribute__((__unused__)),
xasprintf(str, "%"PRIu32, nl->lportid);
return true;
case COL_NETLINK_PROTOCOL:
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));
case COL_SOURCE:
if (major(file->stat.st_dev) == 0
&& strncmp(file->name, "socket:", 7) == 0) {
case COL_SOURCE:
if (major(file->stat.st_dev) == 0
&& strncmp(file->name, "socket:", 7) == 0) {
- str = strdup("sockfs");
+ str = xstrdup("sockfs");
char *name;
if (unkn->anon_ops->class)
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;
/* See unkn_init_content() */
name = ((struct file *)unkn)->name + 11;
return strndup(name + 1, len - 1);
}
return strndup(name + 1, len - 1);
}
}
static bool unkn_fill_column(struct proc *proc,
}
static bool unkn_fill_column(struct proc *proc,
return false;
case COL_SOURCE:
if (unkn->anon_ops) {
return false;
case COL_SOURCE:
if (unkn->anon_ops) {
- str = strdup("anon_inodefs");
+ str = xstrdup("anon_inodefs");
if (pidfd_proc)
pidfd_comm = pidfd_proc->command;
if (pidfd_comm) {
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) {
return true;
}
break;
}
case COL_PIDFD_NSPID:
if (data->nspid) {
- *str = strdup(data->nspid);
+ *str = xstrdup(data->nspid);
"failed to specify a buffer spec to a packet socket");
}
"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) {
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) {