[PATCH v2] Write event stream in file

Ravindra Meena rmeena840 at gmail.com
Tue Jun 25 17:18:51 UTC 2019


---
 misc/record/record-main.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/misc/record/record-main.c b/misc/record/record-main.c
index cd7ef4f..7764109 100644
--- a/misc/record/record-main.c
+++ b/misc/record/record-main.c
@@ -146,20 +146,12 @@ static int connect_client( const char *host, uint16_t port )
 static void print_item( FILE *f, const client_item *item )
 {
   ctf_event ctf_item;
-  uint32_t ns=0;
 
-  if ( item->ns != 0 ) {
-    uint32_t nanoseconds;
-
-    nanoseconds = (uint32_t) ( item->ns % 1000000000 );
-    ns=nanoseconds;
-  }
-    
-  ctf_item.event_id=0;
-  ctf_item.ns=ns;
-  ctf_item.cpu=item->cpu;
-  ctf_item.event=item->event;
-  ctf_item.data=item->data;
+  ctf_item.event_id = 0;
+  ctf_item.ns = ( uint32_t ) ( item->ns % 1000000000 );
+  ctf_item.cpu= item->cpu;
+  ctf_item.event = __builtin_bswap32( item->event );
+  ctf_item.data = item->data;
 
   fwrite( &ctf_item, sizeof( ctf_item ), 1, f );
 
@@ -320,9 +312,9 @@ int main( int argc, char **argv )
   SLIST_INIT( &cctx.free_items );
   RB_INIT( &cctx.active_items );
 
-  FILE *event_stream=fopen("event","wb");
-  assert(event_stream!=NULL);
-  cctx.event_stream=event_stream;
+  FILE *event_stream = fopen( "event" , "wb" );
+  assert( event_stream != NULL );
+  cctx.event_stream = event_stream;
 
   items = calloc( n, sizeof( *items ) );
   assert( items != NULL );
@@ -346,7 +338,7 @@ int main( int argc, char **argv )
     }
   }
 
-  fclose(event_stream);
+  fclose( event_stream );
   rv = close( fd );
   assert( rv == 0 );
 
-- 
2.7.4




More information about the devel mailing list