[RFC PATCH v3 2/5] Refactor scan_fdinfo and decode-fd functions

Sahil icegambit91 at gmail.com
Mon May 13 18:57:16 UTC 2024


Hi,

On Monday, May 13, 2024 5:21:17 PM GMT+5:30 Dmitry V. Levin wrote:
> On Fri, May 10, 2024 at 10:44:08AM +0530, Sahil Siddiq wrote:
> > [...]
> > @@ -734,8 +746,17 @@ get_finfo_for_dev(pid_t pid, int fd, const char *path, struct finfo *finfo)
> >          static const char prefix[] = "tty-index:\t";
> >
> >          finfo->dev.tty_index = -1;
> > -       scan_fdinfo(pid, fd, prefix, sizeof(prefix) - 1,
> > -                             set_tty_index, finfo);
> > +
> > +      struct fdinfo fdinfo_lines[] = {
> > +                {
> > +                          .search_pfx = prefix,
> > +                         .search_pfx_len = sizeof(prefix) - 1,
> > +                         .fn = set_tty_index,
> > +                         .data = finfo
> > +               }
> > +      };
> > +
> > +      scan_fdinfo(pid, fd, fdinfo_lines, ARRAY_SIZE(fdinfo_lines));
> 
> There is an option to give the new edition of scan_fdinfo() a new name,
> e.g. scan_fdinfo_array(), and create an inline wrapper scan_fdinfo()
> around it, this way there won't be any need to patch its call sites.

Sorry, I am not entirely clear on this. Even if a wrapper scan_fdinfo()
is implemented around scan_fdinfo_array(), wouldn't the wrapper have
different parameter types compared to the original scan_fdinfo() which
has char *, size_t and a function pointer "scan_fdinfo_fn" as its parameters?

I haven't understood how this can be implemented without patching the
call sites.

Thanks,
Sahil




More information about the Strace-devel mailing list