ia64/xen-unstable

changeset 17013:7d03c0b07504

xentrace: Fix bug in logic for bytes_to_wrap in trace buffer.
Admittedly, the bug could only be manifest with much larger trace
records than are currently allowed (or equivalently, much smaller
trace buffers), but the old code was harder to read, and thus hid the
logic bug well, too.

Signed-off-by: Michael A Fetterman <Michael.Fetterman@cl.cam.ac.uk>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Feb 11 09:45:36 2008 +0000 (2008-02-11)
parents 1b750b9cf431
children 98e9d5d4b309
files xen/common/trace.c
line diff
     1.1 --- a/xen/common/trace.c	Thu Feb 07 19:30:36 2008 +0000
     1.2 +++ b/xen/common/trace.c	Mon Feb 11 09:45:36 2008 +0000
     1.3 @@ -425,25 +425,18 @@ void __trace_var(u32 event, int cycles, 
     1.4              total_size += bytes_to_wrap;
     1.5              bytes_to_wrap = data_size;
     1.6          } 
     1.7 -        else
     1.8 -        {
     1.9 -            bytes_to_wrap -= LOST_REC_SIZE;
    1.10 -            if ( bytes_to_wrap == 0 )
    1.11 -                bytes_to_wrap = data_size;
    1.12 -        }
    1.13          total_size += LOST_REC_SIZE;
    1.14 +        bytes_to_wrap -= LOST_REC_SIZE;
    1.15 +
    1.16 +        /* LOST_REC might line up perfectly with the buffer wrap */
    1.17 +        if ( bytes_to_wrap == 0 )
    1.18 +            bytes_to_wrap = data_size;
    1.19      }
    1.20  
    1.21      if ( rec_size > bytes_to_wrap )
    1.22      {
    1.23          total_size += bytes_to_wrap;
    1.24 -        bytes_to_wrap = data_size;
    1.25      } 
    1.26 -    else
    1.27 -    {
    1.28 -        bytes_to_wrap -= rec_size;
    1.29 -    }
    1.30 -
    1.31      total_size += rec_size;
    1.32  
    1.33      /* Do we have enough space for everything? */
    1.34 @@ -466,14 +459,12 @@ void __trace_var(u32 event, int cycles, 
    1.35              insert_wrap_record(buf, LOST_REC_SIZE);
    1.36              bytes_to_wrap = data_size;
    1.37          } 
    1.38 -        else
    1.39 -        {
    1.40 -            bytes_to_wrap -= LOST_REC_SIZE;
    1.41 -            /* LOST_REC might line up perfectly with the buffer wrap */
    1.42 -            if ( bytes_to_wrap == 0 )
    1.43 -                bytes_to_wrap = data_size;
    1.44 -        }
    1.45          insert_lost_records(buf);
    1.46 +        bytes_to_wrap -= LOST_REC_SIZE;
    1.47 +
    1.48 +        /* LOST_REC might line up perfectly with the buffer wrap */
    1.49 +        if ( bytes_to_wrap == 0 )
    1.50 +            bytes_to_wrap = data_size;
    1.51      }
    1.52  
    1.53      if ( rec_size > bytes_to_wrap )