libtracefs: Use tracefs_warning() for tracefs_user_event_record() errors
PATCH 1/1 libtracefs: Use tracefs_warning() for tracefs_user_event_record() errors
From: "Steven Rostedt (Google)" <[email protected]>
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.
--- src/tracefs-userevents.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
src/tracefs-userevents.c +3 -3
@@ -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 ; }
Signature · 1 line
2.34.1
Quoted 35 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
Instead of hard coding
fprintf()into the library, allow the application to control the output, and usetracefs_warning()instead. Also switch the setting of the errno, astracefs_warning()will add aperror()to the message.Signed-off-by Steven Rostedt (Google) <[email protected]>--- src/tracefs-userevents.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)src/tracefs-userevents.c +3
-3@@ -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 ; }Signature · 1 line
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
Quoted 28 lines · On Wed, 23 Feb 2022 09:21:19 -0800 Beau Belgrave <[email protected]>…
Quoted 27 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
Instead of hard coding
fprintf()into the library, allow the application to control the output, and usetracefs_warning()instead. Also switch the setting of the errno, astracefs_warning()will add aperror()to the message.Signed-off-by Steven Rostedt (Google) <[email protected]>--- src/tracefs-userevents.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)src/tracefs-userevents.c +2
-2@@ -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 ;
Quoted 11 lines
Quoted 8 lines
src/tracefs-userevents.c +1
-1bad_count: -fprintf (stderr,"Too many user_event items passed\n" ); errno =E2BIG ; +tracefs_warning ("Too many user_event items passed\n" );return -1 ; }Signature · 1 line
2.34.1I think you may want to fix
tracefs-sqlhist.cas well then? I modelled this type of error/warning off what was being done there :)
You mean like this? ;-)
https://lore.kernel.org/all/[email protected]/
-- Steve
Quoted 3 lines
Seems like it would do the same thing when
tracefs_sqlis called and has a buffer error, etc. insql_parse_error()andbuild_filter().
Quoted 43 lines · Steven Rostedt
Quoted 28 lines · On Wed, 23 Feb 2022 09:21:19 -0800 Beau Belgrave <[email protected]>…
Quoted 27 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
Instead of hard coding
fprintf()into the library, allow the application to control the output, and usetracefs_warning()instead. Also switch the setting of the errno, astracefs_warning()will add aperror()to the message.Signed-off-by Steven Rostedt (Google) <[email protected]>--- src/tracefs-userevents.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)src/tracefs-userevents.c +2
-2@@ -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 ;Quoted 11 lines
Quoted 8 lines
src/tracefs-userevents.c +1
-1bad_count: -fprintf (stderr,"Too many user_event items passed\n" ); errno =E2BIG ; +tracefs_warning ("Too many user_event items passed\n" );return -1 ; }Signature · 1 line
2.34.1I think you may want to fix
tracefs-sqlhist.cas well then? I modelled this type of error/warning off what was being done there :)
Quoted 5 lines
You mean like this? ;-)
https://lore.kernel.org/all/[email protected]/
-- Steve
Lol, yep, exactly like that.
-Beau