* [PATCH] libtracefs: Use tracefs_warning() for tracefs_user_event_record() errors
@ 2022-02-23 4:16 Steven Rostedt
2022-02-23 17:21 ` Beau Belgrave
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2022-02-23 4:16 UTC (permalink / raw)
To: Linux Trace Devel; +Cc: Beau Belgrave
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Instead of hard coding fprintf() into the library, allow the application
to control the output, and use tracefs_warning() instead.
Also switch the setting of the errno, as tracefs_warning() will
add a perror() to the message.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
src/tracefs-userevents.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/tracefs-userevents.c b/src/tracefs-userevents.c
index ccd511b3045d..7da6aa35bf12 100644
--- a/src/tracefs-userevents.c
+++ b/src/tracefs-userevents.c
@@ -504,13 +504,13 @@ int tracefs_user_event_record(struct tracefs_user_event *event,
return writev(e->group->fd, head, used);
bad_length:
- fprintf(stderr, "Bad user_event item length at index %d\n",
- used - 1);
errno = EINVAL;
+ tracefs_warning("Bad user_event item length at index %d\n",
+ used - 1);
return -1;
bad_count:
- fprintf(stderr, "Too many user_event items passed\n");
errno = E2BIG;
+ tracefs_warning("Too many user_event items passed\n");
return -1;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] libtracefs: Use tracefs_warning() for tracefs_user_event_record() errors
2022-02-23 4:16 [PATCH] libtracefs: Use tracefs_warning() for tracefs_user_event_record() errors Steven Rostedt
@ 2022-02-23 17:21 ` Beau Belgrave
2022-02-23 17:25 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Beau Belgrave @ 2022-02-23 17:21 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Linux Trace Devel
On Tue, Feb 22, 2022 at 11:16:39PM -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> Instead of hard coding fprintf() into the library, allow the application
> to control the output, and use tracefs_warning() instead.
> Also switch the setting of the errno, as tracefs_warning() will
> add a perror() to the message.
>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> src/tracefs-userevents.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/tracefs-userevents.c b/src/tracefs-userevents.c
> index ccd511b3045d..7da6aa35bf12 100644
> --- a/src/tracefs-userevents.c
> +++ b/src/tracefs-userevents.c
> @@ -504,13 +504,13 @@ int tracefs_user_event_record(struct tracefs_user_event *event,
> return writev(e->group->fd, head, used);
>
> bad_length:
> - fprintf(stderr, "Bad user_event item length at index %d\n",
> - used - 1);
> errno = EINVAL;
> + tracefs_warning("Bad user_event item length at index %d\n",
> + used - 1);
> return -1;
>
> bad_count:
> - fprintf(stderr, "Too many user_event items passed\n");
> errno = E2BIG;
> + tracefs_warning("Too many user_event items passed\n");
> return -1;
> }
> --
> 2.34.1
I think you may want to fix tracefs-sqlhist.c as well then? I modelled
this type of error/warning off what was being done there :)
Seems like it would do the same thing when tracefs_sql is called and has
a buffer error, etc. in sql_parse_error() and build_filter().
Thanks,
-Beau
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] libtracefs: Use tracefs_warning() for tracefs_user_event_record() errors
2022-02-23 17:21 ` Beau Belgrave
@ 2022-02-23 17:25 ` Steven Rostedt
2022-02-23 17:27 ` Beau Belgrave
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2022-02-23 17:25 UTC (permalink / raw)
To: Beau Belgrave; +Cc: Linux Trace Devel
On Wed, 23 Feb 2022 09:21:19 -0800
Beau Belgrave <beaub@linux.microsoft.com> wrote:
> On Tue, Feb 22, 2022 at 11:16:39PM -0500, Steven Rostedt wrote:
> > From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> >
> > Instead of hard coding fprintf() into the library, allow the application
> > to control the output, and use tracefs_warning() instead.
> > Also switch the setting of the errno, as tracefs_warning() will
> > add a perror() to the message.
> >
> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> > ---
> > src/tracefs-userevents.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/tracefs-userevents.c b/src/tracefs-userevents.c
> > index ccd511b3045d..7da6aa35bf12 100644
> > --- a/src/tracefs-userevents.c
> > +++ b/src/tracefs-userevents.c
> > @@ -504,13 +504,13 @@ int tracefs_user_event_record(struct tracefs_user_event *event,
> > return writev(e->group->fd, head, used);
> >
> > bad_length:
> > - fprintf(stderr, "Bad user_event item length at index %d\n",
> > - used - 1);
> > errno = EINVAL;
> > + tracefs_warning("Bad user_event item length at index %d\n",
> > + used - 1);
> > return -1;
> >
> > bad_count:
> > - fprintf(stderr, "Too many user_event items passed\n");
> > errno = E2BIG;
> > + tracefs_warning("Too many user_event items passed\n");
> > return -1;
> > }
> > --
> > 2.34.1
>
> I think you may want to fix tracefs-sqlhist.c as well then? I modelled
> this type of error/warning off what was being done there :)
You mean like this? ;-)
https://lore.kernel.org/all/20220222232045.129e3b6c@rorschach.local.home/
-- Steve
>
> Seems like it would do the same thing when tracefs_sql is called and has
> a buffer error, etc. in sql_parse_error() and build_filter().
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] libtracefs: Use tracefs_warning() for tracefs_user_event_record() errors
2022-02-23 17:25 ` Steven Rostedt
@ 2022-02-23 17:27 ` Beau Belgrave
0 siblings, 0 replies; 4+ messages in thread
From: Beau Belgrave @ 2022-02-23 17:27 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Linux Trace Devel
On Wed, Feb 23, 2022 at 12:25:23PM -0500, Steven Rostedt wrote:
> On Wed, 23 Feb 2022 09:21:19 -0800
> Beau Belgrave <beaub@linux.microsoft.com> wrote:
>
> > On Tue, Feb 22, 2022 at 11:16:39PM -0500, Steven Rostedt wrote:
> > > From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> > >
> > > Instead of hard coding fprintf() into the library, allow the application
> > > to control the output, and use tracefs_warning() instead.
> > > Also switch the setting of the errno, as tracefs_warning() will
> > > add a perror() to the message.
> > >
> > > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> > > ---
> > > src/tracefs-userevents.c | 6 +++---
> > > 1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/src/tracefs-userevents.c b/src/tracefs-userevents.c
> > > index ccd511b3045d..7da6aa35bf12 100644
> > > --- a/src/tracefs-userevents.c
> > > +++ b/src/tracefs-userevents.c
> > > @@ -504,13 +504,13 @@ int tracefs_user_event_record(struct tracefs_user_event *event,
> > > return writev(e->group->fd, head, used);
> > >
> > > bad_length:
> > > - fprintf(stderr, "Bad user_event item length at index %d\n",
> > > - used - 1);
> > > errno = EINVAL;
> > > + tracefs_warning("Bad user_event item length at index %d\n",
> > > + used - 1);
> > > return -1;
> > >
> > > bad_count:
> > > - fprintf(stderr, "Too many user_event items passed\n");
> > > errno = E2BIG;
> > > + tracefs_warning("Too many user_event items passed\n");
> > > return -1;
> > > }
> > > --
> > > 2.34.1
> >
> > I think you may want to fix tracefs-sqlhist.c as well then? I modelled
> > this type of error/warning off what was being done there :)
>
> You mean like this? ;-)
>
> https://lore.kernel.org/all/20220222232045.129e3b6c@rorschach.local.home/
>
> -- Steve
Lol, yep, exactly like that.
-Beau
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-23 17:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-23 4:16 [PATCH] libtracefs: Use tracefs_warning() for tracefs_user_event_record() errors Steven Rostedt
2022-02-23 17:21 ` Beau Belgrave
2022-02-23 17:25 ` Steven Rostedt
2022-02-23 17:27 ` Beau Belgrave
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).