From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2041) id 59B5C3858C2D; Wed, 25 Oct 2023 06:39:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59B5C3858C2D Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Vladimir Mezentsev To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] gprofng: Fix -Wformat= warnings X-Act-Checkin: binutils-gdb X-Git-Author: Vladimir Mezentsev X-Git-Refname: refs/heads/master X-Git-Oldrev: 7ac6d0c38c365a6778a91fd37203c21561c61c4c X-Git-Newrev: 53beac2e23bcffe632bb837c97003998e6986ce9 Message-Id: <20231025063900.59B5C3858C2D@sourceware.org> Date: Wed, 25 Oct 2023 06:39:00 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2023 06:39:00 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D53beac2e23bc= ffe632bb837c97003998e6986ce9 commit 53beac2e23bcffe632bb837c97003998e6986ce9 Author: Vladimir Mezentsev Date: Mon Oct 23 19:55:01 2023 -0700 gprofng: Fix -Wformat=3D warnings =20 Added format attribute to several gprofng functions. Fixed -Wformat=3D warnings. =20 gprofng/ChangeLog 2023-10-23 Vladimir Mezentsev =20 * libcollector/heaptrace.c: Fixed -Wformat=3D 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. Diff: --- 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/heaptr= ace.c index b51ab330ba6..4c1b6b3b0f5 100644 --- a/gprofng/libcollector/heaptrace.c +++ b/gprofng/libcollector/heaptrace.c @@ -24,6 +24,7 @@ =20 #include "config.h" #include +#include =20 #include "gp-defs.h" #include "collector.h" @@ -151,26 +152,34 @@ open_experiment (const char *exp) module_interface.description); =20 /* Record Heap_packet description */ - Heap_packet *pp =3D NULL; collector_interface->writeLog (" \n", HEAP_PCKT); collector_interface->writeLog (" \n", - &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Heap_packet, comm.lwp_id), + fld_sizeof (Heap_packet, comm.lwp_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.thr_id, sizeof (pp->comm.thr_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Heap_packet, comm.thr_id), + fld_sizeof (Heap_packet, comm.thr_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Heap_packet, comm.cpu_id), + fld_sizeof (Heap_packet, comm.cpu_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.tstamp, sizeof (pp->comm.tstamp) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Heap_packet, comm.tstamp), + fld_sizeof (Heap_packet, comm.tstamp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.frinfo, sizeof (pp->comm.frinfo) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Heap_packet, comm.frinfo), + fld_sizeof (Heap_packet, comm.frinfo) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->mtype, sizeof (pp->mtype) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (Heap_packet, mtype), + fld_sizeof (Heap_packet, mtype) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->size, sizeof (pp->size) =3D=3D 4 ? "UINT32" : "UINT64"); + (int) offsetof (Heap_packet, size), + fld_sizeof (Heap_packet, size) =3D=3D 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &pp->vaddr, sizeof (pp->vaddr) =3D=3D 4 ? "UINT32" : "UINT64"); + (int) offsetof (Heap_packet, vaddr), + fld_sizeof (Heap_packet, vaddr) =3D=3D 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &pp->ovaddr, sizeof (pp->ovaddr) =3D=3D 4 ? "UINT32" : "UINT64"); + (int) offsetof (Heap_packet, ovaddr), + fld_sizeof (Heap_packet, ovaddr) =3D=3D 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/hwprof= ile.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 =3D NULL; collector_interface->writeLog ("\n", HW_PCKT); collector_interface->writeLog (" \n", - &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Hwcntr_packet, comm.lwp_id), + fld_sizeof (Hwcntr_packet, comm.lwp_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.thr_id, sizeof (pp->comm.thr_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Hwcntr_packet, comm.thr_id), + fld_sizeof (Hwcntr_packet, comm.thr_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Hwcntr_packet, comm.cpu_id), + fld_sizeof (Hwcntr_packet, comm.cpu_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.tstamp, sizeof (pp->comm.tstamp) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Hwcntr_packet, comm.tstamp), + fld_sizeof (Hwcntr_packet, comm.tstamp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.frinfo, sizeof (pp->comm.frinfo) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Hwcntr_packet, comm.frinfo), + fld_sizeof (Hwcntr_packet, comm.frinfo) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->tag, sizeof (pp->tag) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (Hwcntr_packet, tag), + fld_sizeof (Hwcntr_packet, tag) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->interval, sizeof (pp->interval) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (Hwcntr_packet, interval), + fld_sizeof (Hwcntr_packet, interval) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog ("\n"); if (hwcdef_has_memspace) { /* Record MHwcntr_packet description */ - MHwcntr_packet *xpp =3D NULL; collector_interface->writeLog ("\n", MHWC_PCKT); collector_interface->writeLog (" \n", - &xpp->comm.lwp_id, sizeof (xpp->comm.lwp_id) =3D=3D 4 ? "INT32" := "INT64"); + (int) offsetof (MHwcntr_packet, comm.lwp_id), + fld_sizeof (MHwcntr_packet, comm.lwp_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->comm.thr_id, sizeof (xpp->comm.thr_id) =3D=3D 4 ? "INT32" := "INT64"); + (int) offsetof (MHwcntr_packet, comm.thr_id), + fld_sizeof (MHwcntr_packet, comm.thr_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->comm.cpu_id, sizeof (xpp->comm.cpu_id) =3D=3D 4 ? "INT32" := "INT64"); + (int) offsetof (MHwcntr_packet, comm.cpu_id), + fld_sizeof (MHwcntr_packet, comm.cpu_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->comm.tstamp, sizeof (xpp->comm.tstamp) =3D=3D 4 ? "INT32" := "INT64"); + (int) offsetof (MHwcntr_packet, comm.tstamp), + fld_sizeof (MHwcntr_packet, comm.tstamp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->comm.frinfo, sizeof (xpp->comm.frinfo) =3D=3D 4 ? "INT32" := "INT64"); + (int) offsetof (MHwcntr_packet, comm.frinfo), + fld_sizeof (MHwcntr_packet, comm.frinfo) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \= n", - &xpp->tag, sizeof (xpp->tag) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (MHwcntr_packet, tag), + fld_sizeof (MHwcntr_packet, tag) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->interval, sizeof (xpp->interval) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (MHwcntr_packet, interval), + fld_sizeof (MHwcntr_packet, interval) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->ea_vaddr, sizeof (xpp->ea_vaddr) =3D=3D 4 ? "UINT32" : "UIN= T64"); + (int) offsetof (MHwcntr_packet, ea_vaddr), + fld_sizeof (MHwcntr_packet, ea_vaddr) =3D=3D 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &xpp->ea_paddr, sizeof (xpp->ea_paddr) =3D=3D 4 ? "UINT32" : "UIN= T64"); + (int) offsetof (MHwcntr_packet, ea_paddr), + fld_sizeof (MHwcntr_packet, ea_paddr) =3D=3D 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &xpp->pc_vaddr, sizeof (xpp->pc_vaddr) =3D=3D 4 ? "UINT32" : "UIN= T64"); + (int) offsetof (MHwcntr_packet, pc_vaddr), + fld_sizeof (MHwcntr_packet, pc_vaddr) =3D=3D 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &xpp->pc_paddr, sizeof (xpp->pc_paddr) =3D=3D 4 ? "UINT32" : "UIN= T64"); + (int) offsetof (MHwcntr_packet, pc_paddr), + fld_sizeof (MHwcntr_packet, pc_paddr) =3D=3D 4 ? "UINT32" : "UINT64"); collector_interface->writeLog (" \n", - &xpp->ea_pagesz, sizeof (xpp->ea_pagesz) =3D=3D 4 ? "INT32" : "IN= T64"); + (int) offsetof (MHwcntr_packet, ea_pagesz), + fld_sizeof (MHwcntr_packet, ea_pagesz) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->pc_pagesz, sizeof (xpp->pc_pagesz) =3D=3D 4 ? "INT32" : "IN= T64"); + (int) offsetof (MHwcntr_packet, pc_pagesz), + fld_sizeof (MHwcntr_packet, pc_pagesz) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->ea_lgrp, sizeof (xpp->ea_lgrp) =3D=3D 4 ? "INT32" : "INT64"= ); + (int) offsetof (MHwcntr_packet, ea_lgrp), + fld_sizeof (MHwcntr_packet, ea_lgrp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->pc_lgrp, sizeof (xpp->pc_lgrp) =3D=3D 4 ? "INT32" : "INT64"= ); + (int) offsetof (MHwcntr_packet, pc_lgrp), + fld_sizeof (MHwcntr_packet, pc_lgrp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" = \n", - &xpp->lgrp_lwp, sizeof (xpp->lgrp_lwp) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (MHwcntr_packet, lgrp_lwp), + fld_sizeof (MHwcntr_packet, lgrp_lwp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->lgrp_ps, sizeof (xpp->lgrp_ps) =3D=3D 4 ? "INT32" : "INT64"= ); + (int) offsetof (MHwcntr_packet, lgrp_ps), + fld_sizeof (MHwcntr_packet, lgrp_ps) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n= ", - &xpp->latency, sizeof (xpp->latency) =3D=3D 4 ? "INT32" : "INT64"= ); + (int) offsetof (MHwcntr_packet, latency), + fld_sizeof (MHwcntr_packet, latency) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &xpp->data_source, sizeof (xpp->data_source) =3D=3D 4 ? "INT32" := "INT64"); + (int) offsetof (MHwcntr_packet, data_source), + fld_sizeof (MHwcntr_packet, data_source) =3D=3D 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 =3D __collector_gethrtime (); double deltato =3D (double) (teo - tso) / 1000000.; (void) CALL_UTIL (snprintf) (errmsg, sizeof (errmsg), - " t=3D%d, %s: open-retries=3D%lu, %3.6f ms.; remap\n", + " t=3D%ld, %s: open-retries=3D%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 =20 // 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 =3D NULL; collector_interface->writeLog (" \n", IOTRACE_PCKT); collector_interface->writeLog (" \n", - &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (IOTrace_packet, comm.lwp_id), + fld_sizeof (IOTrace_packet, comm.lwp_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.thr_id, sizeof (pp->comm.thr_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (IOTrace_packet, comm.thr_id), + fld_sizeof (IOTrace_packet, comm.thr_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (IOTrace_packet, comm.cpu_id), + fld_sizeof (IOTrace_packet, comm.cpu_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.tstamp, sizeof (pp->comm.tstamp) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (IOTrace_packet, comm.tstamp), + fld_sizeof (IOTrace_packet, comm.tstamp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.frinfo, sizeof (pp->comm.frinfo) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (IOTrace_packet, comm.frinfo), + fld_sizeof (IOTrace_packet, comm.frinfo) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->iotype, sizeof (pp->iotype) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, iotype), + fld_sizeof (IOTrace_packet, iotype) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->fd, sizeof (pp->fd) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, fd), + fld_sizeof (IOTrace_packet, fd) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->nbyte, sizeof (pp->nbyte) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, nbyte), + fld_sizeof (IOTrace_packet, nbyte) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->requested, sizeof (pp->requested) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, requested), + fld_sizeof (IOTrace_packet, requested) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->ofd, sizeof (pp->ofd) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, ofd), + fld_sizeof (IOTrace_packet, ofd) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->fstype, sizeof (pp->fstype) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (IOTrace_packet, fstype), + fld_sizeof (IOTrace_packet, fstype) =3D=3D 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/jprofil= e.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 =20 @@ -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 =3D 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 =3D collector_interface->getKey (tsd_key); if (tsd) diff --git a/gprofng/libcollector/libcol_util.h b/gprofng/libcollector/libc= ol_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(); =20 /* ------- 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 *rest= rict fmt, ...); +extern int (*__collector_sscanfp)(const char *restrict s, const char *rest= rict 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 dsts= ize); 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 @@ =20 #include "config.h" #include +#include #include #include #include @@ -181,22 +182,28 @@ open_experiment (const char *exp) module_interface.description); =20 /* Record Profile packet description */ - ClockPacket *cp =3D NULL; collector_interface->writeLog (" \n", CLOCK_TYPE); collector_interface->writeLog (" \n", - &cp->lwp_id, sizeof (cp->lwp_id) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, lwp_id), + fld_sizeof (ClockPacket, lwp_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->thr_id, sizeof (cp->thr_id) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, thr_id), + fld_sizeof (ClockPacket, thr_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->cpu_id, sizeof (cp->cpu_id) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, cpu_id), + fld_sizeof (ClockPacket, cpu_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->tstamp, sizeof (cp->tstamp) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, tstamp), + fld_sizeof (ClockPacket, tstamp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->frinfo, sizeof (cp->frinfo) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, frinfo), + fld_sizeof (ClockPacket, frinfo) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->mstate, sizeof (cp->mstate) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, mstate), + fld_sizeof (ClockPacket, mstate) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &cp->nticks, sizeof (cp->nticks) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (ClockPacket, nticks), + fld_sizeof (ClockPacket, nticks) =3D=3D 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/synctr= ace.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 =3D NULL; collector_interface->writeLog (" \n", SYNC_PCKT); collector_interface->writeLog (" \n", - &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Sync_packet, comm.lwp_id), + fld_sizeof (Sync_packet, comm.lwp_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.thr_id, sizeof (pp->comm.thr_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Sync_packet, comm.thr_id), + fld_sizeof (Sync_packet, comm.thr_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Sync_packet, comm.cpu_id), + fld_sizeof (Sync_packet, comm.cpu_id) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.tstamp, sizeof (pp->comm.tstamp) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Sync_packet, comm.tstamp), + fld_sizeof (Sync_packet, comm.tstamp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->comm.frinfo, sizeof (pp->comm.frinfo) =3D=3D 4 ? "INT32" : "INT6= 4"); + (int) offsetof (Sync_packet, comm.frinfo), + fld_sizeof (Sync_packet, comm.frinfo) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->requested, sizeof (pp->requested) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (Sync_packet, requested), + fld_sizeof (Sync_packet, requested) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n", - &pp->objp, sizeof (pp->objp) =3D=3D 4 ? "INT32" : "INT64"); + (int) offsetof (Sync_packet, objp), + fld_sizeof (Sync_packet, objp) =3D=3D 4 ? "INT32" : "INT64"); collector_interface->writeLog (" \n"); collector_interface->writeLog ("\n"); =20 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 =3D %lld"), get_name (), dbeFile->get_location (), - (end_address - start_address)); + (long long) (end_address - start_address)); inst_size =3D 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); }; =20 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 =3D v->get (i); if (p->lineno >=3D 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 =3D=3D 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))); =20 /* 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)) =20 #define PROFILE_BUFFER_CHUNK 16384 +#define fld_sizeof(t, f) (sizeof (((t *)0)->f)) =20 typedef enum {