OSDN Git Service

hprof-conv: Better error message when run on a 1.0.2 file.
authorSiva Velusamy <vsiva@google.com>
Thu, 3 Nov 2011 20:34:29 +0000 (13:34 -0700)
committerSiva Velusamy <vsiva@google.com>
Thu, 3 Nov 2011 20:34:29 +0000 (13:34 -0700)
Change-Id: I36b14aadc11f6ba8a66543546043280da64e7605

tools/hprof-conv/HprofConv.c

index 02cb7f4..bd8bc4f 100644 (file)
@@ -572,6 +572,7 @@ bail:
  */
 static int filterData(FILE* in, FILE* out)
 {
+    const char *magicString;
     ExpandBuf* pBuf;
     int result = -1;
 
@@ -585,8 +586,13 @@ static int filterData(FILE* in, FILE* out)
     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;
     }