On Mon, 20 Jul 2020 at 01:13, Quentin Monnet <quentin@xxxxxxxxxxxxx> wrote: > > On 17/07/2020 23:55, Tony Ambardar wrote: > > The bpftool sources include code to walk file trees, but use multiple > > frameworks to do so: nftw and fts. While nftw conforms to POSIX/SUSv3 and > > is widely available, fts is not conformant and less common, especially on > > non-glibc systems. The inconsistent framework usage hampers maintenance > > and portability of bpftool, in particular for embedded systems. > > > > Standardize code usage by rewriting one fts-based function to use nftw and > > clean up some related function warnings by extending use of "const char *" > > arguments. This change helps in building bpftool against musl for OpenWrt. [...] > > int build_pinned_obj_table(struct pinned_obj_table *tab, > > enum bpf_obj_type type) > > { > > [...] > > > while ((mntent = getmntent(mntfile))) { > > [...] > > > - while ((ftse = fts_read(fts))) { > > [...] > > > + if (nftw(path, do_build_table_cb, nopenfd, flags) == -1) > > + break; > > Sorry I missed that on the previous reviews; but I think a simple break > out of the loop changes the previous behaviour, we should instead > "return -1" from build_pinned_obj_table() if nftw() returns -1, as we > were doing so far. Thanks for the catch. Sorry, that's totally my fault: this was meant to be an "err = nftw(...)" with a "return err" on the common exit path, similar to the rest of the patch. Let me fix and resend. Kind regards, Tony > Looks good otherwise. > > > } > > fclose(mntfile); > > return 0;