hprof-conv: Better error message when run on a 1.0.2 file.
Change-Id: I36b14aadc11f6ba8a66543546043280da64e7605
diff --git a/tools/hprof-conv/HprofConv.c b/tools/hprof-conv/HprofConv.c
index 02cb7f4..bd8bc4f 100644
--- a/tools/hprof-conv/HprofConv.c
+++ b/tools/hprof-conv/HprofConv.c
@@ -572,6 +572,7 @@
*/
static int filterData(FILE* in, FILE* out)
{
+ const char *magicString;
ExpandBuf* pBuf;
int result = -1;
@@ -585,8 +586,13 @@
if (ebReadString(pBuf, in) != 0)
goto bail;
- if (strcmp((const char*)ebGetBuffer(pBuf), "JAVA PROFILE 1.0.3") != 0) {
- fprintf(stderr, "ERROR: expecting 1.0.3\n");
+ magicString = (const char*)ebGetBuffer(pBuf);
+ if (strcmp(magicString, "JAVA PROFILE 1.0.3") != 0) {
+ if (strcmp(magicString, "JAVA PROFILE 1.0.2") == 0) {
+ fprintf(stderr, "ERROR: HPROF file already in 1.0.2 format.\n");
+ } else {
+ fprintf(stderr, "ERROR: expecting HPROF file format 1.0.3\n");
+ }
goto bail;
}