Re: [PATCH 4/7] Remove linux_proc_pid_get_ns

Doug Evans
2015-04-17T04:36:00Z

On Thu, Apr 16, 2015 at 5:19 AM, Gary Benson <gbenson@redhat.com> wrote:
> This commit removes linux_proc_pid_get_ns, and updates its only
> use to use linux_ns_same instead.
>
> gdb/ChangeLog:
>
> * linux-thread-db.c (nat/linux-namespaces.h): New include.
> (check_pid_namespace_match): Use linux_ns_same rather than
> linux_proc_pid_get_ns to spot PID namespace mismatches.
> * nat/linux-procfs.h (linux_proc_pid_get_ns): Remove.
> * nat/linux-procfs.c (linux_proc_pid_get_ns): Likewise.

LGTM.
one nit below

> diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c
> index 44364c5..24bcb01 100644
> --- a/gdb/nat/linux-procfs.c
> +++ b/gdb/nat/linux-procfs.c
> @@ -185,25 +185,6 @@ linux_proc_pid_is_zombie (pid_t pid)
> return linux_proc_pid_is_zombie_maybe_warn (pid, 1);
> }
>
> -/* See linux-procfs.h declaration. */
> -
> -char *
> -linux_proc_pid_get_ns (pid_t pid, const char *ns)
> -{
> - char buf[100];
> - char nsval[64];
> - int ret;
> - xsnprintf (buf, sizeof (buf), "/proc/%d/ns/%s", (int) pid, ns);
> - ret = readlink (buf, nsval, sizeof (nsval));
> - if (0 < ret && ret < sizeof (nsval))
> - {
> - nsval[ret] = '\0';
> - return xstrdup (nsval);
> - }
> -
> - return NULL;
> -}

I see we're using pid_t here.
I think we talked before about a type for pids.
Since this is all linux specific code maybe use pid_t more in this patch set?