Re: [PATCH] libtracefs: Implement tracefs_warning()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 7, 2021 at 7:19 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> On Wed,  7 Apr 2021 08:11:54 +0300
> "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote:
>
> > The warning() function is used in a lot of places in the libracefs
> > library, and it is implemented as a dummy weak function. There is a
> > weak implementation of the same function in traceevent library, which
> > could cause a problem when both are used in an application.
> > Replaced warning() with tracefs_warning() and implemented it as a
> > weak function, specific to this library.
> > Added a __weak define in the library internal header file.
>
> I've been thinking about this more, and I think we only want one function
> to override, and that would be:
>
> void __weak tep_vwarning(const char *name, const char *fmt, va_list ap)
> {
>         if (errno)
>                 perror(name);
>
>         fprintf(stderr, "  ");
>         vfprintf(stderr, fmt, ap);
>         fprintf(stderr, "\n");
> }
>
I understood that idea from your comments, but have a few concerns:

1. That way we create a dependency, not logical to the user of the libraries.
2. That print functionality is not something logically specific to the
libtraceevent, it is not related to the main purpose of this library.
3. A weak function specific to each library is a more straightforward
way and the user has the flexibility to control warnings per library.
The overhead to add library specific wrappers to those weak functions
is not so big.

[...]


-- 
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux