Messages in this thread | | | Date | Mon, 23 Mar 2009 17:57:20 +0100 | From | Daniel Mack <> | Subject | Re: [PATCH] kernel/trace/trace_functions_graph.c: fix nsecs_str buffer size |
| |
Hi Frederic,
On Mon, Mar 23, 2009 at 05:40:31PM +0100, Frederic Weisbecker wrote: > It can't really happen because nsecs_rem is a rest of a division > per 1000, so it will not exceed 3 digits (so it should be [4] and not > [5], btw). > > I must confess I should have added a better comment on this > area. > > We are printing a duration in usec with a part in nsec with the following > constraints: > > _ never exceed 7 characters unless we are are upper 9999999 usecs > _ always keep the usecs consistants > > Which means that while we have 4 or lesser digits for the usecs, we can > print the 3 digits of the nanosecs. > > If we need 5 for usecs, drop the least significant nanosec digit. > If we need 6 for usecs, drop the two least significant nanosec digits
Ok, I see. I was just confused about the max len argument to snprintf() (and so was cppcheck), but at a closer look, this can't become a problem.
Nevermind, drop the patch - but good that we talked about it :)
Daniel
| |