Summary: | use _stp_reserve_bytes for printf buffer | ||
---|---|---|---|
Product: | systemtap | Reporter: | Kent Sebastian <ksebasti> |
Component: | runtime | Assignee: | Kent Sebastian <ksebasti> |
Status: | RESOLVED FIXED | ||
Severity: | enhancement | CC: | dsmith |
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: |
patch _stp_printf and _stp_vsnprintf to allocate exact size printf buffer
patch _stp_printf and _stp_vsnprintf to allocate exact size printf buffer, w/comments |
Description
Kent Sebastian
2008-12-05 19:31:14 UTC
Created attachment 3867 [details]
patch _stp_printf and _stp_vsnprintf to allocate exact size printf buffer
Submitting the changes as a patch instead of committing for some comments. The
printf tests pass on F10 x86 and x86_64, and there are no different failures on
the full testsuite between patched/unpatched.
fche did say to not duplicate code as much as possible but especially with
number(), which returns a char*, getting an integer size out of it would have
been hacky. As well in _stp_vsnprintf putting if statements everywhere didn't
shorten the size of the function but made it much harder to read, so I took
this route.
Any comments/suggestions/flames? :)
(In reply to comment #1) > Created an attachment (id=3867) > patch _stp_printf and _stp_vsnprintf to allocate exact size printf buffer > > Submitting the changes as a patch instead of committing for some comments. The > printf tests pass on F10 x86 and x86_64, and there are no different failures on > the full testsuite between patched/unpatched. > > fche did say to not duplicate code as much as possible but especially with > number(), which returns a char*, getting an integer size out of it would have > been hacky. As well in _stp_vsnprintf putting if statements everywhere didn't > shorten the size of the function but made it much harder to read, so I took > this route. > > Any comments/suggestions/flames? :) I think I see what you are trying to do here. I don't really like the duplicated code, but I also don't see a good way around it. Could you add a comment to the new code in _stp_vsnprintf() mentioning that any changes in it need to be reflected in the code lower down? A comment in the lower part mentioning the reverse might also be a good idea. Created attachment 3889 [details]
patch _stp_printf and _stp_vsnprintf to allocate exact size printf buffer, w/comments
Added comments explaining the requirement to change the corresponding 'sizing'
code.
Committed in 9831040e54178a1b6eb4637213bb3c81f6ed254b. |