[PATCH rtems-tools v1 5/7] TraceWriterQEMU.cc: Fix formatting

Chris Johns chrisj at rtems.org
Tue Sep 21 23:19:33 UTC 2021



On 22/9/21 2:45 am, Ryan Long wrote:
> ---
>  tester/covoar/TraceWriterQEMU.cc | 48 ++++++++++++++++++++++------------------
>  1 file changed, 27 insertions(+), 21 deletions(-)
> 
> diff --git a/tester/covoar/TraceWriterQEMU.cc b/tester/covoar/TraceWriterQEMU.cc
> index 577acab..6f88b3d 100644
> --- a/tester/covoar/TraceWriterQEMU.cc
> +++ b/tester/covoar/TraceWriterQEMU.cc
> @@ -60,9 +60,9 @@ namespace Trace {
>    }
>  
>    bool TraceWriterQEMU::writeFile(
> -    const std::string&         file,
> -    Trace::TraceReaderBase    *log,
> -    bool                       verbose
> +    const std::string&      file,
> +    Trace::TraceReaderBase* log,
> +    bool                    verbose
>    )
>    {
>      struct trace_header header;
> @@ -77,7 +77,7 @@ namespace Trace {
>      //
>      // Verify that the TraceList has a non-zero size.
>      //
> -    if ( log->Trace.set.begin() == log->Trace.set.end() ){
> +    if ( log->Trace.set.begin() == log->Trace.set.end() ) {

Any suitable empty() call?

>        std::cerr << "ERROR: Empty TraceList" << std::endl;
>        return false;
>      }
> @@ -96,13 +96,13 @@ namespace Trace {
>      //
>      //  Write the Header to the file
>      //
> -    strncpy( header.magic, QEMU_TRACE_MAGIC, sizeof(header.magic) );
> -    header.version = QEMU_TRACE_VERSION;
> -    header.kind    = QEMU_TRACE_KIND_RAW;  // XXX ??
> +    strncpy( header.magic, QEMU_TRACE_MAGIC, sizeof( header.magic ) );
> +    header.version          = QEMU_TRACE_VERSION;
> +    header.kind             = QEMU_TRACE_KIND_RAW;  // XXX ??
>      header.sizeof_target_pc = 32;
> -    header.big_endian = false;
> -    header.machine[0] = 0; // XXX ??
> -    header.machine[1] = 0; // XXX ??
> +    header.big_endian       = false;
> +    header.machine[0]       = 0; // XXX ??
> +    header.machine[1]       = 0; // XXX ??
>  
>      traceFile.write( (char *) &header, sizeof( trace_header ) );
>      if ( traceFile.fail() ) {
> @@ -110,30 +110,32 @@ namespace Trace {
>        return false;
>      }
>  
> -    if (verbose)
> +    if ( verbose ) {
>        std::cerr << "magic = " << QEMU_TRACE_MAGIC << std::endl
>                  << "version = " << header.version << std::endl
>                  << "kind = " << header.kind << std::endl
>                  << "sizeof_target_pc = " << header.sizeof_target_pc << std::endl
>                  << "big_endian = " << header.big_endian << std::endl
> -                << std::hex << std::setfill('0')
> -                << "machine = " << std::setw(2) << header.machine[0]
> +                << std::hex << std::setfill( '0' )
> +                << "machine = " << std::setw( 2 ) << header.machine[0]
>                  << ':' << header.machine[1]
> -                << std::dec << std::setfill(' ')
> +                << std::dec << std::setfill( ' ' )
>                  << std::endl;
> +    }
>  
>      //
>      // Loop through log and write each entry.
>      //
>  
> -    for (const auto & itr : log->Trace.set) {
> -      struct trace_entry32  entry;
> +    for ( const auto & itr : log->Trace.set ) {

I prefer to see `auto&` than `auto &`. :)

Chris


More information about the devel mailing list