From: "Prashant Bhole" <bhole_prashant_q7@lab.ntt.co.jp>
To: "'Jakub Kicinski'" <jakub.kicinski@netronome.com>
Cc: "'David S . Miller'" <davem@davemloft.net>,
<netdev@vger.kernel.org>, "'Alexei Starovoitov'" <ast@kernel.org>,
"'Daniel Borkmann'" <daniel@iogearbox.net>,
"'Quentin Monnet'" <quentin.monnet@netronome.com>
Subject: RE: [PATCH net-next V3 2/3] tools: bpftool: show filenames of pinned objects
Date: Wed, 8 Nov 2017 11:34:44 +0900 [thread overview]
Message-ID: <00d801d3583a$23219ff0$6964dfd0$@lab.ntt.co.jp> (raw)
In-Reply-To: <20171107043656.769e4124@cakuba>
> -----Original Message-----
> From: Jakub Kicinski [mailto:jakub.kicinski@netronome.com]
>
> On Mon, 6 Nov 2017 15:06:31 +0900, Prashant Bhole wrote:
> > Added support to show filenames of pinned objects.
> > ...
> > Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
>
> Thanks for the changes, a couple more nit picks, sorry for not spotting
them
> earlier.
>
> > v2:
> > - Dynamically identify bpf-fs moutpoint
> > - Close files descriptors before returning on error
> > - Fixed line break for proper output formatting
> > - Code style: wrapped lines > 80, used reverse christmastree style
> >
> > v3:
> > - Handle multiple bpffs mountpoints
> > - Code style: fixed line break indentation
> >
> > tools/bpf/bpftool/common.c | 85
> ++++++++++++++++++++++++++++++++++++++++++++++
> > tools/bpf/bpftool/main.c | 8 +++++
> > tools/bpf/bpftool/main.h | 17 ++++++++++
> > tools/bpf/bpftool/map.c | 21 ++++++++++++
> > tools/bpf/bpftool/prog.c | 24 +++++++++++++
> > 5 files changed, 155 insertions(+)
> >
> > diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
> > index 4556947709ee..152c5bdbe2e9 100644
> > --- a/tools/bpf/bpftool/common.c
> > +++ b/tools/bpf/bpftool/common.c
> > @@ -45,6 +45,8 @@
> > #include <sys/mount.h>
> > #include <sys/types.h>
> > #include <sys/vfs.h>
> > +#include <mntent.h>
> > +#include <fts.h>
>
> Please try to keep includes in an alphabetical order.
>
> > #include <bpf.h>
> >
> > @@ -290,3 +292,86 @@ void print_hex_data_json(uint8_t *data, size_t len)
> > jsonw_printf(json_wtr, "\"0x%02hhx\"", data[i]);
> > jsonw_end_array(json_wtr);
> > }
> > +
> > +int build_pinned_obj_table(struct pinned_obj_table *tab,
> > + enum bpf_obj_type type)
> > +{
> > + struct bpf_prog_info pinned_info = {};
> > + __u32 len = sizeof(pinned_info);
> > + struct pinned_obj *obj_node = NULL;
> > + enum bpf_obj_type objtype;
> > + struct mntent *mntent = NULL;
>
> Please try to order variable declarations longest to shortest.
>
> > + FILE *mntfile = NULL;
> > + FTSENT *ftse = NULL;
> > + FTS *fts = NULL;
> > + int fd, err;
> > +
> > + mntfile = setmntent("/proc/mounts", "r");
> > + if (!mntfile)
> > + return -1;
> > +
> > + while ((mntent = getmntent(mntfile)) != NULL) {
>
> Please try to avoid comparisons to NULL, writing:
>
> if (ptr)
>
> is more intuitive to most C programmers than:
>
> if (ptr != NULL)
Jakub,
Thank you for comments. I agree with using 'if (ptr)' for simple check, but
here it is an assignment.
It doesn't look intuitive and looks like a typo if I change it to:
while ((mntent = getmntent(mntfile))) {
>
> > + char *path[] = {mntent->mnt_dir, 0};
>
> Shouldn't there be spaces after and before the curly braces? Does
checkpatch --
> strict not warn about this?
I will add spaces. checkpatch complained about this not being static const,
but doing so causes compiler warning because it doesn't match with signature
of fts_open()
I will submit v4 with changes for other comments if you are ok with replies
above.
Prashant
next prev parent reply other threads:[~2017-11-08 2:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 6:06 [PATCH net-next V3 0/3] tools: bpftool: show filenames of pinned objects Prashant Bhole
2017-11-06 6:06 ` [PATCH net-next V3 1/3] tools: bpftool: open pinned object without type check Prashant Bhole
2017-11-06 6:06 ` [PATCH net-next V3 2/3] tools: bpftool: show filenames of pinned objects Prashant Bhole
2017-11-07 12:36 ` Jakub Kicinski
2017-11-08 2:34 ` Prashant Bhole [this message]
2017-11-08 4:33 ` Jakub Kicinski
2017-11-06 6:06 ` [PATCH net-next V3 3/3] tools: bpftool: optionally " Prashant Bhole
2017-11-06 10:45 ` [PATCH net-next V3 0/3] tools: bpftool: " Quentin Monnet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='00d801d3583a$23219ff0$6964dfd0$@lab.ntt.co.jp' \
--to=bhole_prashant_q7@lab.ntt.co.jp \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=jakub.kicinski@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=quentin.monnet@netronome.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).