RFR (and sponsor): 7148488: Whitebox tests for the Diagnostic Framework Parser (original) (raw)

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 < arraylen){_ _const char *nextstr = f->array()->at(i); int nextlen = strlen(nextstr); if (cpos+nextlen+1 > epos){ break; } memcpy(cpos,nextstr,nextlen); *(cpos+nextlen) = ','; cpos+=(nextlen+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 serviceability-dev mailing list