From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [RFC bpf-next 3/4] tools/bpf: bpftool, split the function do_dump() Date: Wed, 19 Sep 2018 08:26:17 -0700 Message-ID: <20180919082617.0967a1cf@cakuba.netronome.com> References: <20180919075143.9308-1-bhole_prashant_q7@lab.ntt.co.jp> <20180919075143.9308-4-bhole_prashant_q7@lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Alexei Starovoitov , Daniel Borkmann , Quentin Monnet , "David S . Miller" , netdev@vger.kernel.org To: Prashant Bhole Return-path: Received: from mail-qk1-f179.google.com ([209.85.222.179]:35918 "EHLO mail-qk1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731744AbeISVEu (ORCPT ); Wed, 19 Sep 2018 17:04:50 -0400 Received: by mail-qk1-f179.google.com with SMTP id n186-v6so2800930qke.3 for ; Wed, 19 Sep 2018 08:26:23 -0700 (PDT) In-Reply-To: <20180919075143.9308-4-bhole_prashant_q7@lab.ntt.co.jp> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 19 Sep 2018 16:51:42 +0900, Prashant Bhole wrote: > +static int dump_map_elem(int fd, void *key, void *value, > + struct bpf_map_info *map_info, struct btf *btf, > + json_writer_t *btf_wtr) > +{ > + int num_elems = 0; > + > + if (!bpf_map_lookup_elem(fd, key, value)) { > + if (json_output) { > + print_entry_json(map_info, key, value, btf); > + } else { > + if (btf) { > + struct btf_dumper d = { > + .btf = btf, > + .jw = btf_wtr, > + .is_plain_text = true, > + }; > + > + do_dump_btf(&d, map_info, key, value); > + } else { > + print_entry_plain(map_info, key, value); > + } > + num_elems++; > + } > + goto out; > + } > + > + /* lookup error handling */ > + if (map_is_map_of_maps(map_info->type) || > + map_is_map_of_progs(map_info->type)) > + goto out; > + nit: why not just return? the goto seems to only do a return anyway, is this suggested by some coding style? Is it to help the compiler? I see people do this from time to time.. [...] > +out: > + return num_elems;