From 53beac2e23bcffe632bb837c97003998e6986ce9 Mon Sep 17 00:00:00 2001 From: Vladimir Mezentsev Date: Mon, 23 Oct 2023 19:55:01 -0700 Subject: [PATCH] gprofng: Fix -Wformat= warnings Added format attribute to several gprofng functions. Fixed -Wformat= warnings. gprofng/ChangeLog 2023-10-23 Vladimir Mezentsev * libcollector/heaptrace.c: Fixed -Wformat= warnings. * libcollector/hwprofile.c: Likewise. * libcollector/iolib.c: Likewise. * libcollector/iotrace.c: Likewise. * libcollector/jprofile.c: Likewise. * libcollector/profile.c: Likewise. * libcollector/synctrace.c: Likewise. * src/ClassFile.cc: Likewise. * src/SourceFile.cc: Likewise. * libcollector/libcol_util.h: Added format attribute. * src/Emsg.h: Likewise. * src/collector_module.h: Likewise. * src/data_pckts.h: Define fld_sizeof. --- gprofng/libcollector/heaptrace.c | 29 +++++++---- gprofng/libcollector/hwprofile.c | 81 +++++++++++++++++++----------- gprofng/libcollector/iolib.c | 2 +- gprofng/libcollector/iotrace.c | 37 +++++++++----- gprofng/libcollector/jprofile.c | 10 ++-- gprofng/libcollector/libcol_util.h | 3 +- gprofng/libcollector/profile.c | 23 ++++++--- gprofng/libcollector/synctrace.c | 23 ++++++--- gprofng/src/ClassFile.cc | 2 +- gprofng/src/Emsg.h | 3 +- gprofng/src/SourceFile.cc | 6 ++- gprofng/src/collector_module.h | 11 ++-- gprofng/src/data_pckts.h | 1 + 13 files changed, 149 insertions(+), 82 deletions(-) diff --git a/gprofng/libcollector/heaptrace.c b/gprofng/libcollector/heaptrace.c index b51ab330ba6..4c1b6b3b0f5 100644 --- a/gprofng/libcollector/heaptrace.c +++ b/gprofng/libcollector/heaptrace.c @@ -24,6 +24,7 @@ #include "config.h" #include +#include #include "gp-defs.h" #include "collector.h" @@ -151,26 +152,34 @@ open_experiment (const char *exp) module_interface.description); /* Record Heap_packet description */ - Heap_packet *pp = NULL; collector_interface->writeLog (" \n", HEAP_PCKT); collector_interface->writeLog (" \n", - &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (Heap_packet, comm.lwp_id), + fld_sizeof (Heap_packet, comm.lwp_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.thr_id, sizeof (pp->comm.thr_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (Heap_packet, comm.thr_id), + fld_sizeof (Heap_packet, comm.thr_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (Heap_packet, comm.cpu_id), + fld_sizeof (Heap_packet, comm.cpu_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.tstamp, sizeof (pp->comm.tstamp) == 4 ? "INT32" : "INT64"); + (int) offsetof (Heap_packet, comm.tstamp), + fld_sizeof (Heap_packet, comm.tstamp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.frinfo, sizeof (pp->comm.frinfo) == 4 ? "INT32" : "INT64"); + (int) offsetof (Heap_packet, comm.frinfo), + fld_sizeof (Heap_packet, comm.frinfo) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->mtype, sizeof (pp->mtype) == 4 ? "INT32" : "INT64"); + (int) offsetof (Heap_packet, mtype), + fld_sizeof (Heap_packet, mtype) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->size, sizeof (pp->size) == 4 ? "UINT32" : "UINT64"); + (int) offsetof (Heap_packet, size), + fld_sizeof (Heap_packet, size) == 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &pp->vaddr, sizeof (pp->vaddr) == 4 ? "UINT32" : "UINT64"); + (int) offsetof (Heap_packet, vaddr), + fld_sizeof (Heap_packet, vaddr) == 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &pp->ovaddr, sizeof (pp->ovaddr) == 4 ? "UINT32" : "UINT64"); + (int) offsetof (Heap_packet, ovaddr), + fld_sizeof (Heap_packet, ovaddr) == 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n"); collector_interface->writeLog ("\n"); return COL_ERROR_NONE; diff --git a/gprofng/libcollector/hwprofile.c b/gprofng/libcollector/hwprofile.c index 3ca89d1ceb6..092d665e618 100644 --- a/gprofng/libcollector/hwprofile.c +++ b/gprofng/libcollector/hwprofile.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -823,66 +824,90 @@ hwclogwrite0 () collector_interface->writeLog ("\n", module_interface.description); /* Record Hwcntr_packet description */ - Hwcntr_packet *pp = NULL; collector_interface->writeLog ("\n", HW_PCKT); collector_interface->writeLog (" \n", - &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (Hwcntr_packet, comm.lwp_id), + fld_sizeof (Hwcntr_packet, comm.lwp_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.thr_id, sizeof (pp->comm.thr_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (Hwcntr_packet, comm.thr_id), + fld_sizeof (Hwcntr_packet, comm.thr_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (Hwcntr_packet, comm.cpu_id), + fld_sizeof (Hwcntr_packet, comm.cpu_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.tstamp, sizeof (pp->comm.tstamp) == 4 ? "INT32" : "INT64"); + (int) offsetof (Hwcntr_packet, comm.tstamp), + fld_sizeof (Hwcntr_packet, comm.tstamp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.frinfo, sizeof (pp->comm.frinfo) == 4 ? "INT32" : "INT64"); + (int) offsetof (Hwcntr_packet, comm.frinfo), + fld_sizeof (Hwcntr_packet, comm.frinfo) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->tag, sizeof (pp->tag) == 4 ? "INT32" : "INT64"); + (int) offsetof (Hwcntr_packet, tag), + fld_sizeof (Hwcntr_packet, tag) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->interval, sizeof (pp->interval) == 4 ? "INT32" : "INT64"); + (int) offsetof (Hwcntr_packet, interval), + fld_sizeof (Hwcntr_packet, interval) == 4 ? "INT32" : "INT64"); collector_interface->writeLog ("\n"); if (hwcdef_has_memspace) { /* Record MHwcntr_packet description */ - MHwcntr_packet *xpp = NULL; collector_interface->writeLog ("\n", MHWC_PCKT); collector_interface->writeLog (" \n", - &xpp->comm.lwp_id, sizeof (xpp->comm.lwp_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, comm.lwp_id), + fld_sizeof (MHwcntr_packet, comm.lwp_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->comm.thr_id, sizeof (xpp->comm.thr_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, comm.thr_id), + fld_sizeof (MHwcntr_packet, comm.thr_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->comm.cpu_id, sizeof (xpp->comm.cpu_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, comm.cpu_id), + fld_sizeof (MHwcntr_packet, comm.cpu_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->comm.tstamp, sizeof (xpp->comm.tstamp) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, comm.tstamp), + fld_sizeof (MHwcntr_packet, comm.tstamp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->comm.frinfo, sizeof (xpp->comm.frinfo) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, comm.frinfo), + fld_sizeof (MHwcntr_packet, comm.frinfo) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->tag, sizeof (xpp->tag) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, tag), + fld_sizeof (MHwcntr_packet, tag) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->interval, sizeof (xpp->interval) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, interval), + fld_sizeof (MHwcntr_packet, interval) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->ea_vaddr, sizeof (xpp->ea_vaddr) == 4 ? "UINT32" : "UINT64"); + (int) offsetof (MHwcntr_packet, ea_vaddr), + fld_sizeof (MHwcntr_packet, ea_vaddr) == 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &xpp->ea_paddr, sizeof (xpp->ea_paddr) == 4 ? "UINT32" : "UINT64"); + (int) offsetof (MHwcntr_packet, ea_paddr), + fld_sizeof (MHwcntr_packet, ea_paddr) == 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &xpp->pc_vaddr, sizeof (xpp->pc_vaddr) == 4 ? "UINT32" : "UINT64"); + (int) offsetof (MHwcntr_packet, pc_vaddr), + fld_sizeof (MHwcntr_packet, pc_vaddr) == 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &xpp->pc_paddr, sizeof (xpp->pc_paddr) == 4 ? "UINT32" : "UINT64"); + (int) offsetof (MHwcntr_packet, pc_paddr), + fld_sizeof (MHwcntr_packet, pc_paddr) == 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &xpp->ea_pagesz, sizeof (xpp->ea_pagesz) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, ea_pagesz), + fld_sizeof (MHwcntr_packet, ea_pagesz) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->pc_pagesz, sizeof (xpp->pc_pagesz) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, pc_pagesz), + fld_sizeof (MHwcntr_packet, pc_pagesz) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->ea_lgrp, sizeof (xpp->ea_lgrp) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, ea_lgrp), + fld_sizeof (MHwcntr_packet, ea_lgrp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->pc_lgrp, sizeof (xpp->pc_lgrp) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, pc_lgrp), + fld_sizeof (MHwcntr_packet, pc_lgrp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->lgrp_lwp, sizeof (xpp->lgrp_lwp) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, lgrp_lwp), + fld_sizeof (MHwcntr_packet, lgrp_lwp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->lgrp_ps, sizeof (xpp->lgrp_ps) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, lgrp_ps), + fld_sizeof (MHwcntr_packet, lgrp_ps) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->latency, sizeof (xpp->latency) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, latency), + fld_sizeof (MHwcntr_packet, latency) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->data_source, sizeof (xpp->data_source) == 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, data_source), + fld_sizeof (MHwcntr_packet, data_source) == 4 ? "INT32" : "INT64"); collector_interface->writeLog ("\n"); } } diff --git a/gprofng/libcollector/iolib.c b/gprofng/libcollector/iolib.c index 9de481430de..96fdd258fd0 100644 --- a/gprofng/libcollector/iolib.c +++ b/gprofng/libcollector/iolib.c @@ -640,7 +640,7 @@ remapBlock (DataHandle *hndl, unsigned iflow, unsigned ichunk) hrtime_t teo = __collector_gethrtime (); double deltato = (double) (teo - tso) / 1000000.; (void) CALL_UTIL (snprintf) (errmsg, sizeof (errmsg), - " t=%d, %s: open-retries=%lu, %3.6f ms.; remap\n", + " t=%ld, %s: open-retries=%d, %3.6f ms.; remap\n", (unsigned long) __collector_thr_self (), hndl->fname, iter, deltato); __collector_log_write ("%s\n", diff --git a/gprofng/libcollector/iotrace.c b/gprofng/libcollector/iotrace.c index 81c844048d9..7ed9c99126b 100644 --- a/gprofng/libcollector/iotrace.c +++ b/gprofng/libcollector/iotrace.c @@ -25,6 +25,7 @@ #include #include #include +#include #include // create() and others are defined in fcntl.h. @@ -305,32 +306,42 @@ open_experiment (const char *exp) collector_interface->writeLog (" \n", module_interface.description); /* Record IOTrace_packet description */ - IOTrace_packet *pp = NULL; collector_interface->writeLog (" \n", IOTRACE_PCKT); collector_interface->writeLog (" \n", - &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, comm.lwp_id), + fld_sizeof (IOTrace_packet, comm.lwp_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.thr_id, sizeof (pp->comm.thr_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, comm.thr_id), + fld_sizeof (IOTrace_packet, comm.thr_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, comm.cpu_id), + fld_sizeof (IOTrace_packet, comm.cpu_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.tstamp, sizeof (pp->comm.tstamp) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, comm.tstamp), + fld_sizeof (IOTrace_packet, comm.tstamp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.frinfo, sizeof (pp->comm.frinfo) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, comm.frinfo), + fld_sizeof (IOTrace_packet, comm.frinfo) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->iotype, sizeof (pp->iotype) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, iotype), + fld_sizeof (IOTrace_packet, iotype) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->fd, sizeof (pp->fd) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, fd), + fld_sizeof (IOTrace_packet, fd) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->nbyte, sizeof (pp->nbyte) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, nbyte), + fld_sizeof (IOTrace_packet, nbyte) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->requested, sizeof (pp->requested) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, requested), + fld_sizeof (IOTrace_packet, requested) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->ofd, sizeof (pp->ofd) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, ofd), + fld_sizeof (IOTrace_packet, ofd) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->fstype, sizeof (pp->fstype) == 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, fstype), + fld_sizeof (IOTrace_packet, fstype) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->fname, "STRING"); + (int) offsetof (IOTrace_packet, fname), "STRING"); collector_interface->writeLog (" \n"); collector_interface->writeLog ("\n"); return COL_ERROR_NONE; diff --git a/gprofng/libcollector/jprofile.c b/gprofng/libcollector/jprofile.c index 4bec99950fc..130da19c060 100644 --- a/gprofng/libcollector/jprofile.c +++ b/gprofng/libcollector/jprofile.c @@ -28,7 +28,7 @@ #include #include #include /* MAXPATHLEN */ - +#include #include #include @@ -628,8 +628,8 @@ jvmti_ThreadStart (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread) group_name, parent_name, (unsigned long) tid, - thread, - jni_env + (unsigned long) thread, + (unsigned long) jni_env ); TSD_Entry *tsd = collector_interface->getKey (tsd_key); if (tsd) @@ -648,8 +648,8 @@ jvmti_ThreadEnd (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread) SP_JCMD_JTHREND, (unsigned) (hrt / NANOSEC), (unsigned) (hrt % NANOSEC), (unsigned long) tid, - thread, - jni_env + (unsigned long) thread, + (unsigned long) jni_env ); TSD_Entry *tsd = collector_interface->getKey (tsd_key); if (tsd) diff --git a/gprofng/libcollector/libcol_util.h b/gprofng/libcollector/libcol_util.h index bb9411493f6..c21b4a46c4b 100644 --- a/gprofng/libcollector/libcol_util.h +++ b/gprofng/libcollector/libcol_util.h @@ -38,7 +38,8 @@ extern void __collector_libscf_funcs_init(); /* ------- functions from libcol_util.c ----------------- */ extern void * __collector_memcpy (void *s1, const void *s2, size_t n); -extern int (*__collector_sscanfp)(const char *restrict s, const char *restrict fmt, ...); +extern int (*__collector_sscanfp)(const char *restrict s, const char *restrict fmt, ...) + __attribute__ ((format (scanf, 2, 3))); extern char * __collector_strcat (char *s1, const char *s2); extern char * __collector_strchr (const char *s1, int chr); extern size_t __collector_strlcpy (char *dst, const char *src, size_t dstsize); diff --git a/gprofng/libcollector/profile.c b/gprofng/libcollector/profile.c index 4819d832b31..02c3e669bd2 100644 --- a/gprofng/libcollector/profile.c +++ b/gprofng/libcollector/profile.c @@ -27,6 +27,7 @@ #include "config.h" #include +#include #include #include #include @@ -181,22 +182,28 @@ open_experiment (const char *exp) module_interface.description); /* Record Profile packet description */ - ClockPacket *cp = NULL; collector_interface->writeLog (" \n", CLOCK_TYPE); collector_interface->writeLog (" \n", - &cp->lwp_id, sizeof (cp->lwp_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, lwp_id), + fld_sizeof (ClockPacket, lwp_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->thr_id, sizeof (cp->thr_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, thr_id), + fld_sizeof (ClockPacket, thr_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->cpu_id, sizeof (cp->cpu_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, cpu_id), + fld_sizeof (ClockPacket, cpu_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->tstamp, sizeof (cp->tstamp) == 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, tstamp), + fld_sizeof (ClockPacket, tstamp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->frinfo, sizeof (cp->frinfo) == 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, frinfo), + fld_sizeof (ClockPacket, frinfo) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->mstate, sizeof (cp->mstate) == 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, mstate), + fld_sizeof (ClockPacket, mstate) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->nticks, sizeof (cp->nticks) == 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, nticks), + fld_sizeof (ClockPacket, nticks) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n"); collector_interface->writeLog ("\n"); return COL_ERROR_NONE; diff --git a/gprofng/libcollector/synctrace.c b/gprofng/libcollector/synctrace.c index 565afbe742f..4c4d80dcb24 100644 --- a/gprofng/libcollector/synctrace.c +++ b/gprofng/libcollector/synctrace.c @@ -26,6 +26,7 @@ #include #include #include /* sem_wait() */ +#include #include #include #include @@ -252,22 +253,28 @@ open_experiment (const char *exp) collector_interface->writeLog (" \n", module_interface.description); /* Record Sync_packet description */ - Sync_packet *pp = NULL; collector_interface->writeLog (" \n", SYNC_PCKT); collector_interface->writeLog (" \n", - &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (Sync_packet, comm.lwp_id), + fld_sizeof (Sync_packet, comm.lwp_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.thr_id, sizeof (pp->comm.thr_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (Sync_packet, comm.thr_id), + fld_sizeof (Sync_packet, comm.thr_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) == 4 ? "INT32" : "INT64"); + (int) offsetof (Sync_packet, comm.cpu_id), + fld_sizeof (Sync_packet, comm.cpu_id) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.tstamp, sizeof (pp->comm.tstamp) == 4 ? "INT32" : "INT64"); + (int) offsetof (Sync_packet, comm.tstamp), + fld_sizeof (Sync_packet, comm.tstamp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.frinfo, sizeof (pp->comm.frinfo) == 4 ? "INT32" : "INT64"); + (int) offsetof (Sync_packet, comm.frinfo), + fld_sizeof (Sync_packet, comm.frinfo) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->requested, sizeof (pp->requested) == 4 ? "INT32" : "INT64"); + (int) offsetof (Sync_packet, requested), + fld_sizeof (Sync_packet, requested) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->objp, sizeof (pp->objp) == 4 ? "INT32" : "INT64"); + (int) offsetof (Sync_packet, objp), + fld_sizeof (Sync_packet, objp) == 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n"); collector_interface->writeLog ("\n"); diff --git a/gprofng/src/ClassFile.cc b/gprofng/src/ClassFile.cc index 0f1d468c967..d59c9630ef1 100644 --- a/gprofng/src/ClassFile.cc +++ b/gprofng/src/ClassFile.cc @@ -1594,7 +1594,7 @@ ClassFile::get_disasm (uint64_t inst_address, uint64_t end_address, { append_msg (CMSG_ERROR, GTXT ("Cannot disassemble class file %s (%s), implausible size = %lld"), get_name (), dbeFile->get_location (), - (end_address - start_address)); + (long long) (end_address - start_address)); inst_size = 0; return NULL; } diff --git a/gprofng/src/Emsg.h b/gprofng/src/Emsg.h index bed664baa2b..9dbaceab11e 100644 --- a/gprofng/src/Emsg.h +++ b/gprofng/src/Emsg.h @@ -105,7 +105,8 @@ public: Vector *msgs; void remove_msg (Emsg *msg); Emsg *get_error (); - Emsg *append_msg (Cmsg_warn w, const char *fmt, ...); + Emsg *append_msg (Cmsg_warn w, const char *fmt, ...) + __attribute__ ((format (printf, 3, 4))); void append_msgs (Vector *lst); }; diff --git a/gprofng/src/SourceFile.cc b/gprofng/src/SourceFile.cc index 35629cccd54..f3809c8d9aa 100644 --- a/gprofng/src/SourceFile.cc +++ b/gprofng/src/SourceFile.cc @@ -135,7 +135,8 @@ SourceFile::readSource () DbeLine *p = v->get (i); if (p->lineno >= srcLines->size ()) append_msg (CMSG_ERROR, GTXT ("Wrong line number %d. '%s' has only %d lines"), - p->lineno, dbeFile->get_location (), srcLines->size ()); + (int) p->lineno, dbeFile->get_location (), + (int) srcLines->size ()); } delete v; } @@ -167,7 +168,8 @@ SourceFile::find_dbeline (Function *func, int lineno) if (dbeLine == NULL) append_msg (CMSG_ERROR, GTXT ("Wrong line number %d. '%s' has only %d lines"), - lineno, dbeFile->get_location (), lines->size ()); + (int) lineno, dbeFile->get_location (), + (int) lines->size ()); } else { diff --git a/gprofng/src/collector_module.h b/gprofng/src/collector_module.h index 07bf362ddb7..67dcad643ed 100644 --- a/gprofng/src/collector_module.h +++ b/gprofng/src/collector_module.h @@ -53,7 +53,8 @@ typedef struct CollectorUtilFuncs char *(*fgets)(char *s, int n, FILE *stream); FILE *(*fopen)(const char *filename, const char *mode); pid_t (*vfork)(); - int (*fprintf)(FILE *stream, const char *format, ...); + int (*fprintf)(FILE *stream, const char *format, ...) + __attribute__ ((format (printf, 2, 3))); void (*free)(void *ptr); int (*fstat)(int fd, struct stat *buf); int (*getcontext)(ucontext_t *ucp); @@ -82,7 +83,8 @@ typedef struct CollectorUtilFuncs int (*setenv)(const char *name, const char *value, int overwrite); int (*sigfillset)(sigset_t *set); int (*sigprocmask)(int how, const sigset_t *set, sigset_t *oldset); - int (*snprintf)(char *str, size_t size, const char *format, ...); + int (*snprintf)(char *str, size_t size, const char *format, ...) + __attribute__ ((format (printf, 3, 4))); int (*stack_getbounds)(); char *(*strchr)(const char *name, int c); int (*strcmp)(const char *s1, const char *s2); @@ -168,12 +170,13 @@ typedef struct CollectorInterface CollectorModule (*registerModule)(struct ModuleInterface*); const char *(*getParams)(); const char *(*getExpDir)(); - int (*writeLog)(char *format, ...); + int (*writeLog)(char *format, ...) __attribute__ ((format (printf, 1, 2))); FrameInfo (*getFrameInfo)(CollectorModule modl, HiResTime ts, int mode, void *arg); FrameInfo (*getUID)(CM_Array *arg); FrameInfo (*getUID2)(CM_Array *arg, FrameInfo uid); int (*getStackTrace)(void *buf, int size, void *bptr, void *eptr, void *arg); - int (*writeMetaData)(CollectorModule modl, char *format, ...); + int (*writeMetaData)(CollectorModule modl, char *format, ...) + __attribute__ ((format (printf, 2, 3))); /* writeDataRecord ensures that the header is filled in, and then calls writeDataPacket */ int (*writeDataRecord)(CollectorModule modl, struct Common_packet *pckt); diff --git a/gprofng/src/data_pckts.h b/gprofng/src/data_pckts.h index 484edae9edb..eecd4e905f3 100644 --- a/gprofng/src/data_pckts.h +++ b/gprofng/src/data_pckts.h @@ -51,6 +51,7 @@ typedef uint32_t Size_type; /* size_t for 32 bit apps */ #define SP_FAILED_UNWIND_MARKER ((uint64_t)(-3)) #define PROFILE_BUFFER_CHUNK 16384 +#define fld_sizeof(t, f) (sizeof (((t *)0)->f)) typedef enum { -- 2.30.2