RFR (and sponsor): 7148488: Whitebox tests for the Diagnostic Framework Parser
Nils Loodin
nils.loodin at oracle.com
Wed Mar 21 10:05:39 PDT 2012
Updated webrev as per Dmitrys' comments as well!
http://cr.openjdk.java.net/~nloodin/7148488/webrev.03/
To anser questions:
> 1. It seems to me if array doesn't fit to buf we have spare coma at the
> end. Is it intentional?
No, but it doesn't matter. Test will fail and buffer will have to be adjusted.
>
> 2. We don't check whether we have enough room for comma in a buf. So we
> can overflow it.
Good catch. Fixed.
>
> So I would recommend to reformat it something like below:
>
> int i = 0;
> char *cpos = buf,*epos = buf+len;
>
> while(i < array_len){
> const char *next_str = f->array()->at(i);
> int next_len = strlen(next_str);
>
> if (cpos+next_len+1 > epos){
> break;
> }
>
> memcpy(cpos,next_str,next_len);
> *(cpos+next_len) = ',';
> cpos+=(next_len+1);
> }
>
> epos = (cpos == buf) ? cpos : cpos-1;
> *epos = 0;
>
I fixed the issue with the comma, but built it on my code, as I found that
more readable.. hope it doesn't matter!
Regards
Nils Loodin
/Nisse
More information about the hotspot-dev
mailing list