Print this page
rev 7131 : 8049049: Unportable format string argument mismatch in hotspot/agent/src/os/solaris/proc/saproc.cpp
Summary: Cast arguments on printing
Reviewed-by: dholmes, sspitsyn, jbachorik

Split Split Close
Expand all
Collapse all
          --- old/hotspot/agent/src/os/solaris/proc/saproc.cpp
          +++ new/hotspot/agent/src/os/solaris/proc/saproc.cpp
↓ open down ↓ 306 lines elided ↑ open up ↑
 307  307        handle = dlopen(alt_path, mode);
 308  308        if (_libsaproc_debug && handle) {
 309  309          printf("libsaproc DEBUG: pathmap_dlopen substituted %s\n", alt_path);
 310  310        }
 311  311      }
 312  312    }
 313  313    if (handle == NULL) {
 314  314      handle = dlopen(name, mode);
 315  315    }
 316  316    if (_libsaproc_debug) {
 317      -    printf("libsaproc DEBUG: pathmap_dlopen %s return 0x%x\n", name, handle);
      317 +    printf("libsaproc DEBUG: pathmap_dlopen %s return 0x%lx\n", name, (unsigned long) handle);
 318  318    }
 319  319    return handle;
 320  320  }
 321  321  
 322  322  // libproc and libthread_db callback functions
 323  323  
 324  324  extern "C" {
 325  325  
 326  326  static int
 327  327  init_libthread_db_ptrs(void *cd, const prmap_t *pmp, const char *object_name) {
↓ open down ↓ 326 lines elided ↑ open up ↑
 654  654    struct FileMapHeader* pheader = (struct FileMapHeader*) malloc(sizeof(struct FileMapHeader));
 655  655    if (pheader == NULL) {
 656  656      close(fd);
 657  657      THROW_NEW_DEBUGGER_EXCEPTION_("can't allocate memory for shared file map header", 1);
 658  658    }
 659  659  
 660  660    memset(pheader, 0, sizeof(struct FileMapHeader));
 661  661    // read FileMapHeader
 662  662    size_t n = read(fd, pheader, sizeof(struct FileMapHeader));
 663  663    if (n != sizeof(struct FileMapHeader)) {
 664      -    free(pheader);
 665      -    close(fd);
 666  664      char errMsg[ERR_MSG_SIZE];
 667  665      sprintf(errMsg, "unable to read shared archive file map header from %s", classes_jsa);
      666 +    close(fd);
      667 +    free(pheader);
 668  668      THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 669  669    }
 670  670  
 671  671    // check file magic
 672  672    if (pheader->_magic != 0xf00baba2) {
 673      -    free(pheader);
 674      -    close(fd);
 675  673      char errMsg[ERR_MSG_SIZE];
 676  674      sprintf(errMsg, "%s has bad shared archive magic 0x%x, expecting 0xf00baba2",
 677  675                     classes_jsa, pheader->_magic);
      676 +    close(fd);
      677 +    free(pheader);
 678  678      THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 679  679    }
 680  680  
 681  681    // check version
 682  682    if (pheader->_version != CURRENT_ARCHIVE_VERSION) {
 683      -    free(pheader);
 684      -    close(fd);
 685  683      char errMsg[ERR_MSG_SIZE];
 686  684      sprintf(errMsg, "%s has wrong shared archive version %d, expecting %d",
 687  685                     classes_jsa, pheader->_version, CURRENT_ARCHIVE_VERSION);
      686 +    close(fd);
      687 +    free(pheader);
 688  688      THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 689  689    }
 690  690  
 691  691    if (_libsaproc_debug) {
 692  692      for (int m = 0; m < NUM_SHARED_MAPS; m++) {
 693  693         print_debug("shared file offset %d mapped at 0x%lx, size = %ld, read only? = %d\n",
 694  694            pheader->_space[m]._file_offset, pheader->_space[m]._base,
 695  695            pheader->_space[m]._used, pheader->_space[m]._read_only);
 696  696      }
 697  697    }
↓ open down ↓ 753 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX