From: Roland Schulz Date: Fri, 13 Jul 2018 04:22:12 +0000 (-0700) Subject: Warn for type mismatch for gmx printf like functions 1/3 X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=4c266b2978bcb205b6ab63a2bcb38c085c19baf5;p=alexxy%2Fgromacs.git Warn for type mismatch for gmx printf like functions 1/3 Automatic fixes with clang fix-it Related #2570 Change-Id: Id565d2705c673d1e45318bb8bf1091c165a724de --- diff --git a/src/gromacs/awh/bias.cpp b/src/gromacs/awh/bias.cpp index 1a18b0d18e..4310aef885 100644 --- a/src/gromacs/awh/bias.cpp +++ b/src/gromacs/awh/bias.cpp @@ -241,7 +241,7 @@ static void ensureStateAndRunConsistency(const BiasParams ¶ms, gmx_int64_t numUpdatesExpected = state.histogramSize().numUpdates(); if (numUpdatesFromSamples != numUpdatesExpected) { - std::string mesg = gmx::formatString("The number of AWH updates in the checkpoint file (%ld) does not match the total number of AWH samples divided by the number of samples per update for %ld sharing AWH bias(es) (%ld/%ld=%ld)", + std::string mesg = gmx::formatString("The number of AWH updates in the checkpoint file (%ld) does not match the total number of AWH samples divided by the number of samples per update for %d sharing AWH bias(es) (%ld/%d=%ld)", numUpdatesExpected, params.numSharedUpdate, numSamples, diff --git a/src/gromacs/awh/biasstate.cpp b/src/gromacs/awh/biasstate.cpp index 9cd6a2ec8a..029620dc07 100644 --- a/src/gromacs/awh/biasstate.cpp +++ b/src/gromacs/awh/biasstate.cpp @@ -1524,7 +1524,7 @@ static void readUserPmfAndTargetDistribution(const std::vector &dimPa if (numColumns < numColumnsMin) { std::string mesg = - gmx::formatString("The number of columns in %s (%d) should be at least %d." + gmx::formatString("The number of columns in %s (%s) should be at least %d." "\n\n%s", filename.c_str(), correctFormatMessage.c_str()); GMX_THROW(InvalidInputError(mesg)); @@ -1570,7 +1570,7 @@ static void readUserPmfAndTargetDistribution(const std::vector &dimPa /* Check if the values are allowed. */ if (target < 0) { - std::string mesg = gmx::formatString("Target distribution weight at point %d (%g) in %s is negative.", + std::string mesg = gmx::formatString("Target distribution weight at point %zu (%g) in %s is negative.", m, target, filename.c_str()); GMX_THROW(InvalidInputError(mesg)); } diff --git a/src/gromacs/awh/read-params.cpp b/src/gromacs/awh/read-params.cpp index 414fbe8723..c8008f1598 100644 --- a/src/gromacs/awh/read-params.cpp +++ b/src/gromacs/awh/read-params.cpp @@ -449,7 +449,7 @@ static void checkInputConsistencyAwh(const AwhParams &awhParams, sprintf(errormsg, "One pull coordinate (%d) cannot be mapped to two separate AWH dimensions (awh%d-dim%d and awh%d-dim%d). " "If this is really what you want to do you will have to duplicate this pull coordinate.", awhBiasParams1.dimParams[d1].coordIndex + 1, k1 + 1, d1 + 1, k2 + 1, d2 + 1); - gmx_fatal(FARGS, errormsg); + gmx_fatal(FARGS, "%s", errormsg); } } } @@ -703,7 +703,7 @@ static void checkInputConsistencyInterval(const AwhParams *awhParams, warninp_t if ((period == 0) && (origin > end)) { - gmx_fatal(FARGS, "For the non-periodic pull coordinates awh%d-dim%d-start cannot be larger than awh%d-dim%d-end", + gmx_fatal(FARGS, "For the non-periodic pull coordinates awh%d-dim%d-start cannot be larger than awh%f-dim%d-end", k + 1, d + 1, origin, k + 1, d + 1, end); } diff --git a/src/gromacs/correlationfunctions/autocorr.cpp b/src/gromacs/correlationfunctions/autocorr.cpp index a9681ce215..61dc522a28 100644 --- a/src/gromacs/correlationfunctions/autocorr.cpp +++ b/src/gromacs/correlationfunctions/autocorr.cpp @@ -231,7 +231,7 @@ static void do_ac_core(int nframes, int nout, } else { - gmx_fatal(FARGS, "\nInvalid mode (%d) in do_ac_core", mode); + gmx_fatal(FARGS, "\nInvalid mode (%lu) in do_ac_core", mode); } } } @@ -519,7 +519,7 @@ static void do_four_core(unsigned long mode, int nframes, } else { - gmx_fatal(FARGS, "\nUnknown mode in do_autocorr (%d)", mode); + gmx_fatal(FARGS, "\nUnknown mode in do_autocorr (%lu)", mode); } sfree(cfour); diff --git a/src/gromacs/domdec/cellsizes.cpp b/src/gromacs/domdec/cellsizes.cpp index c30b302647..4db4992a24 100644 --- a/src/gromacs/domdec/cellsizes.cpp +++ b/src/gromacs/domdec/cellsizes.cpp @@ -308,11 +308,11 @@ set_dd_cell_sizes_slb(gmx_domdec_t *dd, const gmx_ddbox_t *ddbox, if (setmode == setcellsizeslbLOCAL) { gmx_fatal_collective(FARGS, dd->mpi_comm_all, DDMASTER(dd), - error_string); + "%s", error_string); } else { - gmx_fatal(FARGS, error_string); + gmx_fatal(FARGS, "%s", error_string); } } } diff --git a/src/gromacs/domdec/domdec.cpp b/src/gromacs/domdec/domdec.cpp index 6c87d0dff1..60e6c0cb10 100644 --- a/src/gromacs/domdec/domdec.cpp +++ b/src/gromacs/domdec/domdec.cpp @@ -3353,7 +3353,7 @@ static int forceDlbOffOrBail(int cmdlineDlbState, if (cmdlineDlbState == edlbsOnUser) { - gmx_fatal(FARGS, (dlbNotSupportedErr + reasonStr).c_str()); + gmx_fatal(FARGS, "%s", (dlbNotSupportedErr + reasonStr).c_str()); } else if (cmdlineDlbState == edlbsOffCanTurnOn) { @@ -6482,7 +6482,7 @@ void dd_partition_system(FILE *fplog, { if (state_local->ddp_count > dd->ddp_count) { - gmx_fatal(FARGS, "Internal inconsistency state_local->ddp_count (%d) > dd->ddp_count (%d)", state_local->ddp_count, dd->ddp_count); + gmx_fatal(FARGS, "Internal inconsistency state_local->ddp_count (%d) > dd->ddp_count (%ld)", state_local->ddp_count, dd->ddp_count); } if (state_local->ddp_count_cg_gl != state_local->ddp_count) diff --git a/src/gromacs/domdec/domdec_setup.cpp b/src/gromacs/domdec/domdec_setup.cpp index 22e3687d7c..2e3f2a8fdd 100644 --- a/src/gromacs/domdec/domdec_setup.cpp +++ b/src/gromacs/domdec/domdec_setup.cpp @@ -768,7 +768,7 @@ real dd_choose_grid(FILE *fplog, /* Check if the largest divisor is more than nnodes^2/3 */ if (ldiv*ldiv*ldiv > nnodes_div*nnodes_div) { - gmx_fatal(FARGS, "The number of ranks you selected (%d) contains a large prime factor %d. In most cases this will lead to bad performance. Choose a number with smaller prime factors or set the decomposition (option -dd) manually.", + gmx_fatal(FARGS, "The number of ranks you selected (%ld) contains a large prime factor %ld. In most cases this will lead to bad performance. Choose a number with smaller prime factors or set the decomposition (option -dd) manually.", nnodes_div, ldiv); } } diff --git a/src/gromacs/domdec/domdec_topology.cpp b/src/gromacs/domdec/domdec_topology.cpp index 647d58f06f..959d0879ce 100644 --- a/src/gromacs/domdec/domdec_topology.cpp +++ b/src/gromacs/domdec/domdec_topology.cpp @@ -432,7 +432,7 @@ void dd_print_missing_interactions(FILE *fplog, t_commrec *cr, { errorMessage = gmx::formatString("%d of the %d bonded interactions could not be calculated because some atoms involved moved further apart than the multi-body cut-off distance (%g nm) or the two-body cut-off distance (%g nm), see option -rdd, for pairs and tabulated bonds also see option -ddcheck", -ndiff_tot, cr->dd->nbonded_global, dd_cutoff_multibody(dd), dd_cutoff_twobody(dd)); } - gmx_fatal_collective(FARGS, cr->mpi_comm_mygroup, MASTER(cr), errorMessage.c_str()); + gmx_fatal_collective(FARGS, cr->mpi_comm_mygroup, MASTER(cr), "%s", errorMessage.c_str()); } /*! \brief Return global topology molecule information for global atom index \p i_gl */ diff --git a/src/gromacs/ewald/pme-load-balancing.cpp b/src/gromacs/ewald/pme-load-balancing.cpp index 4347f70bcb..e08289db77 100644 --- a/src/gromacs/ewald/pme-load-balancing.cpp +++ b/src/gromacs/ewald/pme-load-balancing.cpp @@ -789,7 +789,7 @@ pme_load_balance(pme_load_balancing_t *pme_lb, * But we implement a complete failsafe solution anyhow. */ GMX_LOG(mdlog.warning).asParagraph().appendTextFormatted( - "The fastest PP/PME load balancing setting (cutoff %.3f nm) is no longer available due to DD DLB or box size limitations", pme_lb->fastest); + "The fastest PP/PME load balancing setting (cutoff %.3d nm) is no longer available due to DD DLB or box size limitations", pme_lb->fastest); pme_lb->fastest = pme_lb->lower_limit; pme_lb->start = pme_lb->lower_limit; } diff --git a/src/gromacs/fileio/checkpoint.cpp b/src/gromacs/fileio/checkpoint.cpp index eb5a338dc3..8cb2c57891 100644 --- a/src/gromacs/fileio/checkpoint.cpp +++ b/src/gromacs/fileio/checkpoint.cpp @@ -1961,7 +1961,7 @@ void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep, } else { - gmx_warning(buf); + gmx_warning("%s", buf); } } diff --git a/src/gromacs/fileio/enxio.cpp b/src/gromacs/fileio/enxio.cpp index cfff421eab..4990ce5de2 100644 --- a/src/gromacs/fileio/enxio.cpp +++ b/src/gromacs/fileio/enxio.cpp @@ -333,7 +333,7 @@ static void enx_warning(const char *msg) { if (getenv("GMX_ENX_NO_FATAL") != nullptr) { - gmx_warning(msg); + gmx_warning("%s", msg); } else { diff --git a/src/gromacs/fileio/tpxio.cpp b/src/gromacs/fileio/tpxio.cpp index d59b34b429..59a829691a 100644 --- a/src/gromacs/fileio/tpxio.cpp +++ b/src/gromacs/fileio/tpxio.cpp @@ -2600,7 +2600,7 @@ static void do_tpxheader(t_fileio *fio, gmx_bool bRead, t_tpxheader *tpx, if ((precision != sizeof(float)) && !bDouble) { gmx_fatal(FARGS, "Unknown precision in file %s: real is %d bytes " - "instead of %d or %d", + "instead of %lu or %lu", gmx_fio_getname(fio), precision, sizeof(float), sizeof(double)); } gmx_fio_setprecision(fio, bDouble); diff --git a/src/gromacs/gmxana/gmx_hydorder.cpp b/src/gromacs/gmxana/gmx_hydorder.cpp index 312a70a57e..4fe52c384e 100644 --- a/src/gromacs/gmxana/gmx_hydorder.cpp +++ b/src/gromacs/gmxana/gmx_hydorder.cpp @@ -665,7 +665,7 @@ int gmx_hydorder(int argc, char *argv[]) gmx::ArrayRef intfn = opt2fns("-o", NFILE, fnm); if (intfn.size() != 2) { - gmx_fatal(FARGS, "No or not correct number (2) of output-files: %d", intfn.size()); + gmx_fatal(FARGS, "No or not correct number (2) of output-files: %ld", intfn.size()); } calc_tetra_order_interface(ndxfnm, tpsfnm, trxfnm, binwidth, nsttblock, &frames, &xslices, &yslices, sg1, sg2, &intfpos, oenv); writesurftoxpms(intfpos, frames, xslices, yslices, binwidth, intfn, nlevels); @@ -675,7 +675,7 @@ int gmx_hydorder(int argc, char *argv[]) gmx::ArrayRef spectra = opt2fns("-Spect", NFILE, fnm); if (spectra.size() != 2) { - gmx_fatal(FARGS, "No or not correct number (2) of output-files: %d", spectra.size()); + gmx_fatal(FARGS, "No or not correct number (2) of output-files: %ld", spectra.size()); } powerspectavg(intfpos, frames, xslices, yslices, spectra); } @@ -685,7 +685,7 @@ int gmx_hydorder(int argc, char *argv[]) gmx::ArrayRef raw = opt2fns("-or", NFILE, fnm); if (raw.size() != 2) { - gmx_fatal(FARGS, "No or not correct number (2) of output-files: %d", raw.size()); + gmx_fatal(FARGS, "No or not correct number (2) of output-files: %ld", raw.size()); } writeraw(intfpos, frames, xslices, yslices, raw); } diff --git a/src/gromacs/gmxana/gmx_make_edi.cpp b/src/gromacs/gmxana/gmx_make_edi.cpp index c488d16d40..e01913d4fb 100644 --- a/src/gromacs/gmxana/gmx_make_edi.cpp +++ b/src/gromacs/gmxana/gmx_make_edi.cpp @@ -291,12 +291,12 @@ static int sscan_list(int *list[], const char *str, const char *listname) /* format error occured */ case sError: - gmx_fatal(FARGS, "Error in the list of eigenvectors for %s at pos %d with char %c", listname, pos-startpos, *(pos-1)); + gmx_fatal(FARGS, "Error in the list of eigenvectors for %s at pos %ld with char %c", listname, pos-startpos, *(pos-1)); /* logical error occured */ case sZero: - gmx_fatal(FARGS, "Error in the list of eigenvectors for %s at pos %d: eigenvector 0 is not valid", listname, pos-startpos); + gmx_fatal(FARGS, "Error in the list of eigenvectors for %s at pos %ld: eigenvector 0 is not valid", listname, pos-startpos); case sSmaller: - gmx_fatal(FARGS, "Error in the list of eigenvectors for %s at pos %d: second index %d is not bigger than %d", listname, pos-startpos, end_number, number); + gmx_fatal(FARGS, "Error in the list of eigenvectors for %s at pos %ld: second index %d is not bigger than %d", listname, pos-startpos, end_number, number); } ++pos; /* read next character */ } /*scanner has finished */ diff --git a/src/gromacs/gmxana/gmx_nmr.cpp b/src/gromacs/gmxana/gmx_nmr.cpp index ad8ba9393f..2a8c650d56 100644 --- a/src/gromacs/gmxana/gmx_nmr.cpp +++ b/src/gromacs/gmxana/gmx_nmr.cpp @@ -833,7 +833,7 @@ int gmx_nmr(int argc, char *argv[]) if (blk->sub[0].nr != nex*12) { - gmx_fatal(FARGS, "Number of orientation experiments in energy file (%g) does not match with the topology (%d)", + gmx_fatal(FARGS, "Number of orientation experiments in energy file (%d) does not match with the topology (%d)", blk->sub[0].nr/12, nex); } fprintf(foten, " %10f", fr.t); diff --git a/src/gromacs/gmxana/gmx_wham.cpp b/src/gromacs/gmxana/gmx_wham.cpp index ac718cb6b8..2a291d3c29 100644 --- a/src/gromacs/gmxana/gmx_wham.cpp +++ b/src/gromacs/gmxana/gmx_wham.cpp @@ -417,7 +417,7 @@ static void setup_tab(const char *fn, t_UmbrellaOptions *opt) { if (std::abs(y[0][i+1]-y[0][i]-opt->tabDz) > opt->tabDz/1e6) { - gmx_fatal(FARGS, "z-values in %s are not equally spaced.\n", ny, fn); + gmx_fatal(FARGS, "z-values in %d are not equally spaced.\n", ny, fn); } } snew(opt->tabY, nl); @@ -1392,7 +1392,7 @@ static void create_synthetic_histo(t_UmbrellaWindow *synthWindow, t_UmbrellaWind "3) If all ACTs are identical and know, you can define them with -bs-tau.\n" " Use option (3) only if you are sure what you're doing, you may severely\n" " underestimate the error if a too small ACT is given.\n"); - gmx_fatal(FARGS, errstr); + gmx_fatal(FARGS, "%s", errstr); } synthWindow->N [0] = N; diff --git a/src/gromacs/gmxpreprocess/fflibutil.cpp b/src/gromacs/gmxpreprocess/fflibutil.cpp index c906fea25e..812a229856 100644 --- a/src/gromacs/gmxpreprocess/fflibutil.cpp +++ b/src/gromacs/gmxpreprocess/fflibutil.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2010,2012,2013,2014,2015,2017, by the GROMACS development team, led by + * Copyright (c) 2010,2012,2013,2014,2015,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -84,7 +84,7 @@ void fflib_filename_base(const char *filename, char *filebase, int maxlen) } if (strlen(filename) >= (size_t)maxlen) { - gmx_fatal(FARGS, "filename is longer (%d) than maxlen (%d)", + gmx_fatal(FARGS, "filename is longer (%zu) than maxlen (%d)", strlen(filename), maxlen); } strcpy(filebase, cptr); diff --git a/src/gromacs/gmxpreprocess/pdb2gmx.cpp b/src/gromacs/gmxpreprocess/pdb2gmx.cpp index c172d03ab2..bf63bfbb60 100644 --- a/src/gromacs/gmxpreprocess/pdb2gmx.cpp +++ b/src/gromacs/gmxpreprocess/pdb2gmx.cpp @@ -750,7 +750,7 @@ static void sort_pdbatoms(t_restp restp[], "Note that hydrogens might have been added to the entry for the N-terminus.\n" "Remove this hydrogen or choose a different protonation state to solve it.\n" "Option -ignh will ignore all hydrogens in the input." : "."); - gmx_fatal(FARGS, buf); + gmx_fatal(FARGS, "%s", buf); } /* make shadow array to be sorted into indexgroup */ pdbi[i].resnr = pdba->atom[i].resind; @@ -1599,7 +1599,7 @@ int gmx_pdb2gmx(int argc, char *argv[]) bVsiteAromatics = TRUE; break; default: - gmx_fatal(FARGS, "DEATH HORROR in $s (%d): vsitestr[0]='%s'", + gmx_fatal(FARGS, "DEATH HORROR in $s (%s): vsitestr[0]='%d'", __FILE__, __LINE__, vsitestr[0]); } /* end switch */ diff --git a/src/gromacs/gmxpreprocess/pdb2top.cpp b/src/gromacs/gmxpreprocess/pdb2top.cpp index 2eab21ae49..d9c0c80f19 100644 --- a/src/gromacs/gmxpreprocess/pdb2top.cpp +++ b/src/gromacs/gmxpreprocess/pdb2top.cpp @@ -1092,7 +1092,7 @@ void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp, } else { - gmx_fatal(FARGS, errString); + gmx_fatal(FARGS, "%s", errString); } } else if (bRM && ((tern >= 0 && ntdb[tern]->nhack == 0) || @@ -1105,7 +1105,7 @@ void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp, } else { - gmx_fatal(FARGS, errString); + gmx_fatal(FARGS, "%s", errString); } } } diff --git a/src/gromacs/gmxpreprocess/pgutil.cpp b/src/gromacs/gmxpreprocess/pgutil.cpp index a4418abf9a..a86ad7a35a 100644 --- a/src/gromacs/gmxpreprocess/pgutil.cpp +++ b/src/gromacs/gmxpreprocess/pgutil.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2012,2014,2015,2017, by the GROMACS development team, led by + * Copyright (c) 2012,2014,2015,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -81,7 +81,7 @@ static void atom_not_found(int fatal_errno, const char *file, int line, } else { - gmx_fatal(fatal_errno, file, line, message_buffer); + gmx_fatal(fatal_errno, file, line, "%s", message_buffer); } } } diff --git a/src/gromacs/gmxpreprocess/readir.cpp b/src/gromacs/gmxpreprocess/readir.cpp index 55bd2db67e..1e49192d1d 100644 --- a/src/gromacs/gmxpreprocess/readir.cpp +++ b/src/gromacs/gmxpreprocess/readir.cpp @@ -175,7 +175,7 @@ static void GetSimTemps(int ntemps, t_simtemp *simtemp, double *temperature_lamb { char errorstr[128]; sprintf(errorstr, "eSimTempScale=%d not defined", simtemp->eSimTempScale); - gmx_fatal(FARGS, errorstr); + gmx_fatal(FARGS, "%s", errorstr); } } } diff --git a/src/gromacs/gmxpreprocess/topdirs.cpp b/src/gromacs/gmxpreprocess/topdirs.cpp index dcb2a2bcae..91e57fa837 100644 --- a/src/gromacs/gmxpreprocess/topdirs.cpp +++ b/src/gromacs/gmxpreprocess/topdirs.cpp @@ -275,7 +275,7 @@ int ifunc_index(directive d, int type) case d_dihedral_restraints: return F_DIHRES; default: - gmx_fatal(FARGS, "invalid directive %s in ifunc_index (%s:%s)", + gmx_fatal(FARGS, "invalid directive %s in ifunc_index (%s:%d)", dir2str(d), __FILE__, __LINE__); } } diff --git a/src/gromacs/gmxpreprocess/topio.cpp b/src/gromacs/gmxpreprocess/topio.cpp index 0e529d1c16..ecfc20ecf4 100644 --- a/src/gromacs/gmxpreprocess/topio.cpp +++ b/src/gromacs/gmxpreprocess/topio.cpp @@ -479,7 +479,7 @@ static char **read_topol(const char *infile, const char *outfile, status = cpp_open_file(infile, &handle, cpp_opts(define, include, wi)); if (status != 0) { - gmx_fatal(FARGS, cpp_error(&handle, status)); + gmx_fatal(FARGS, "%s", cpp_error(&handle, status)); } /* some local variables */ @@ -516,7 +516,7 @@ static char **read_topol(const char *infile, const char *outfile, { if (status != eCPP_OK) { - gmx_fatal(FARGS, cpp_error(&handle, status)); + gmx_fatal(FARGS, "%s", cpp_error(&handle, status)); } else if (out) { @@ -556,7 +556,7 @@ static char **read_topol(const char *infile, const char *outfile, { if (status != eCPP_OK) { - gmx_fatal(FARGS, cpp_error(&handle, status)); + gmx_fatal(FARGS, "%s", cpp_error(&handle, status)); } else if (out) { @@ -913,7 +913,7 @@ static char **read_topol(const char *infile, const char *outfile, status = cpp_close_file(&handle); if (status != eCPP_OK) { - gmx_fatal(FARGS, cpp_error(&handle, status)); + gmx_fatal(FARGS, "%s", cpp_error(&handle, status)); } cpp_done(); if (out) diff --git a/src/gromacs/gmxpreprocess/toputil.cpp b/src/gromacs/gmxpreprocess/toputil.cpp index db5c07197d..1a5108bc02 100644 --- a/src/gromacs/gmxpreprocess/toputil.cpp +++ b/src/gromacs/gmxpreprocess/toputil.cpp @@ -67,7 +67,7 @@ void set_p_string(t_param *p, const char *s) } else { - gmx_fatal(FARGS, "Increase MAXSLEN in the grompp code to at least %d," + gmx_fatal(FARGS, "Increase MAXSLEN in the grompp code to at least %lu," " or shorten your definition of bonds like %s to at most %d", strlen(s)+1, s, MAXSLEN-1); } diff --git a/src/gromacs/hardware/printhardware.cpp b/src/gromacs/hardware/printhardware.cpp index c8662b5d2f..6c660063a5 100644 --- a/src/gromacs/hardware/printhardware.cpp +++ b/src/gromacs/hardware/printhardware.cpp @@ -312,12 +312,12 @@ static std::string detected_hardware_string(const gmx_hw_info_t *hwinfo, s += gmx::formatString(" Latency:\n "); for (std::size_t j = 0; j < hwTop.machine().numa.nodes.size(); j++) { - s += gmx::formatString(" %5d", j); + s += gmx::formatString(" %5lu", j); } s += gmx::formatString("\n"); for (std::size_t i = 0; i < hwTop.machine().numa.nodes.size(); i++) { - s += gmx::formatString(" %5d", i); + s += gmx::formatString(" %5lu", i); for (std::size_t j = 0; j < hwTop.machine().numa.nodes.size(); j++) { s += gmx::formatString(" %5.2f", hwTop.machine().numa.relativeLatency[i][j]); diff --git a/src/gromacs/listed-forces/manage-threading.cpp b/src/gromacs/listed-forces/manage-threading.cpp index 7ae8fc6b42..8312e98d3c 100644 --- a/src/gromacs/listed-forces/manage-threading.cpp +++ b/src/gromacs/listed-forces/manage-threading.cpp @@ -450,7 +450,7 @@ void setup_bonded_threading(bonded_threading_t *bt, if (gmx_debug_at) { #if BITMASK_SIZE <= 64 //move into bitmask when it is C++ - std::string flags = gmx::formatString("%x", *mask); + std::string flags = gmx::formatString("%lx", *mask); #else std::string flags = gmx::formatAndJoin(*mask, *mask+BITMASK_ALEN, diff --git a/src/gromacs/mdlib/expanded.cpp b/src/gromacs/mdlib/expanded.cpp index 9744ed48ab..2a1d3a50dc 100644 --- a/src/gromacs/mdlib/expanded.cpp +++ b/src/gromacs/mdlib/expanded.cpp @@ -906,7 +906,7 @@ static int ChooseNewLambda(int nlim, t_expanded *expand, df_history_t *dfhist, i { loc += sprintf(&errorstr[loc], "%3d %17.10e%17.10e%17.10e\n", ifep, weighted_lamee[ifep], p_k[ifep], dfhist->sum_weights[ifep]); } - gmx_fatal(FARGS, errorstr); + gmx_fatal(FARGS, "%s", errorstr); } } } diff --git a/src/gromacs/mdlib/forcerec.cpp b/src/gromacs/mdlib/forcerec.cpp index a2a076cce7..b7bcdb28d0 100644 --- a/src/gromacs/mdlib/forcerec.cpp +++ b/src/gromacs/mdlib/forcerec.cpp @@ -2334,7 +2334,7 @@ void init_forcerec(FILE *fp, if (check_box(ir->ePBC, box)) { - gmx_fatal(FARGS, check_box(ir->ePBC, box)); + gmx_fatal(FARGS, "%s", check_box(ir->ePBC, box)); } /* Test particle insertion ? */ @@ -2730,7 +2730,7 @@ void init_forcerec(FILE *fp, { if (!gmx_within_tol(ic->reppow, 12.0, 10*GMX_DOUBLE_EPS)) { - gmx_fatal(FARGS, "Cut-off scheme %S only supports LJ repulsion power 12", ecutscheme_names[ir->cutoff_scheme]); + gmx_fatal(FARGS, "Cut-off scheme %s only supports LJ repulsion power 12", ecutscheme_names[ir->cutoff_scheme]); } /* Older tpr files can contain Coulomb user tables with the Verlet cutoff-scheme, * while mdrun does not (and never did) support this. diff --git a/src/gromacs/mdlib/gmx_omp_nthreads.cpp b/src/gromacs/mdlib/gmx_omp_nthreads.cpp index b642651f44..148604469c 100644 --- a/src/gromacs/mdlib/gmx_omp_nthreads.cpp +++ b/src/gromacs/mdlib/gmx_omp_nthreads.cpp @@ -211,7 +211,7 @@ void gmx_omp_nthreads_read_env(const gmx::MDLogger &mdlog, /* This prints once per simulation for multi-simulations, * which might help diagnose issues with inhomogenous * cluster setups. */ - GMX_LOG(mdlog.info).appendTextFormatted(buffer); + GMX_LOG(mdlog.info).appendTextFormatted("%s", buffer); if (debug) { /* This prints once per process for real MPI (i.e. once diff --git a/src/gromacs/mdlib/lincs.cpp b/src/gromacs/mdlib/lincs.cpp index 40cbc8a321..83981ce01b 100644 --- a/src/gromacs/mdlib/lincs.cpp +++ b/src/gromacs/mdlib/lincs.cpp @@ -1319,7 +1319,7 @@ static void set_lincs_matrix_task(Lincs *li, li_task->ntriangle++; if (li->blnr[i+1] - li->blnr[i] > static_cast(sizeof(li_task->tri_bits[0])*8 - 1)) { - gmx_fatal(FARGS, "A constraint is connected to %d constraints, this is more than the %d allowed for constraints participating in triangles", + gmx_fatal(FARGS, "A constraint is connected to %d constraints, this is more than the %lu allowed for constraints participating in triangles", li->blnr[i+1] - li->blnr[i], sizeof(li_task->tri_bits[0])*8-1); } diff --git a/src/gromacs/mdlib/mdebin.cpp b/src/gromacs/mdlib/mdebin.cpp index 6c57df84f1..642a961688 100644 --- a/src/gromacs/mdlib/mdebin.cpp +++ b/src/gromacs/mdlib/mdebin.cpp @@ -1566,7 +1566,7 @@ void restore_energyhistory_from_state(t_mdebin * mdebin, if ((enerhist->nsum > 0 && nener != enerhist->ener_sum.size()) || (enerhist->nsum_sim > 0 && nener != enerhist->ener_sum_sim.size())) { - gmx_fatal(FARGS, "Mismatch between number of energies in run input (%d) and checkpoint file (%u or %u).", + gmx_fatal(FARGS, "Mismatch between number of energies in run input (%d) and checkpoint file (%zu or %zu).", nener, enerhist->ener_sum.size(), enerhist->ener_sum_sim.size()); } diff --git a/src/gromacs/mdlib/nbnxn_search.cpp b/src/gromacs/mdlib/nbnxn_search.cpp index 7e8263869e..0248a5d1a5 100644 --- a/src/gromacs/mdlib/nbnxn_search.cpp +++ b/src/gromacs/mdlib/nbnxn_search.cpp @@ -1727,7 +1727,7 @@ static void make_fep_list(const nbnxn_search *nbs, if (ngid*gridj->na_cj > gmx::index(sizeof(gid_cj)*8)) { - gmx_fatal(FARGS, "The Verlet scheme with %dx%d kernels and free-energy only supports up to %d energy groups", + gmx_fatal(FARGS, "The Verlet scheme with %dx%d kernels and free-energy only supports up to %lu energy groups", gridi->na_c, gridj->na_cj, (sizeof(gid_cj)*8)/gridj->na_cj); } diff --git a/src/gromacs/mdlib/nbnxn_tuning.cpp b/src/gromacs/mdlib/nbnxn_tuning.cpp index b63702e075..663b7d18af 100644 --- a/src/gromacs/mdlib/nbnxn_tuning.cpp +++ b/src/gromacs/mdlib/nbnxn_tuning.cpp @@ -323,7 +323,7 @@ void increaseNstlist(FILE *fp, t_commrec *cr, if (!bBox || !bDD) { - gmx_warning(!bBox ? box_err : dd_err); + gmx_warning("%s", !bBox ? box_err : dd_err); if (fp != nullptr) { fprintf(fp, "\n%s\n", !bBox ? box_err : dd_err); @@ -471,7 +471,7 @@ static std::string formatListSetup(const std::string &listName, } listSetup += "updated every "; // Make the shortest int format string that fits nstListForSpacing - std::string nstListFormat = "%" + gmx::formatString("%d", gmx::formatString("%zu", nstListForSpacing).size()) + "d"; + std::string nstListFormat = "%" + gmx::formatString("%lu", gmx::formatString("%d", nstListForSpacing).size()) + "d"; listSetup += gmx::formatString(nstListFormat.c_str(), nstList); listSetup += gmx::formatString(" steps, buffer %.3f nm, rlist %.3f nm\n", rList - interactionCutoff, rList); diff --git a/src/gromacs/mdlib/shellfc.cpp b/src/gromacs/mdlib/shellfc.cpp index 693435a530..3041ad3cd2 100644 --- a/src/gromacs/mdlib/shellfc.cpp +++ b/src/gromacs/mdlib/shellfc.cpp @@ -503,7 +503,7 @@ gmx_shellfc_t *init_shell_flexcon(FILE *fplog, case F_ANHARM_POL: if (!gmx_within_tol(qS, atom[aS].qB, GMX_REAL_EPS*10)) { - gmx_fatal(FARGS, "polarize can not be used with qA(%e) != qB(%e) for atom %d of molecule block %d", qS, atom[aS].qB, aS+1, mb+1); + gmx_fatal(FARGS, "polarize can not be used with qA(%e) != qB(%e) for atom %d of molecule block %lu", qS, atom[aS].qB, aS+1, mb+1); } shell[nsi].k += gmx::square(qS)*ONE_4PI_EPS0/ ffparams->iparams[type].polarize.alpha; @@ -511,7 +511,7 @@ gmx_shellfc_t *init_shell_flexcon(FILE *fplog, case F_WATER_POL: if (!gmx_within_tol(qS, atom[aS].qB, GMX_REAL_EPS*10)) { - gmx_fatal(FARGS, "water_pol can not be used with qA(%e) != qB(%e) for atom %d of molecule block %d", qS, atom[aS].qB, aS+1, mb+1); + gmx_fatal(FARGS, "water_pol can not be used with qA(%e) != qB(%e) for atom %d of molecule block %lu", qS, atom[aS].qB, aS+1, mb+1); } alpha = (ffparams->iparams[type].wpol.al_x+ ffparams->iparams[type].wpol.al_y+ diff --git a/src/gromacs/mdrun/md.cpp b/src/gromacs/mdrun/md.cpp index 82e8550e3e..1b0f144e66 100644 --- a/src/gromacs/mdrun/md.cpp +++ b/src/gromacs/mdrun/md.cpp @@ -789,11 +789,11 @@ void gmx::Integrator::do_md() { if (!rerun_fr.bBox) { - gmx_fatal(FARGS, "Rerun trajectory frame step %d time %f does not contain a box, while pbc is used", rerun_fr.step, rerun_fr.time); + gmx_fatal(FARGS, "Rerun trajectory frame step %ld time %f does not contain a box, while pbc is used", rerun_fr.step, rerun_fr.time); } if (max_cutoff2(ir->ePBC, rerun_fr.box) < gmx::square(fr->rlist)) { - gmx_fatal(FARGS, "Rerun trajectory frame step %d time %f has too small box dimensions", rerun_fr.step, rerun_fr.time); + gmx_fatal(FARGS, "Rerun trajectory frame step %ld time %f has too small box dimensions", rerun_fr.step, rerun_fr.time); } } } diff --git a/src/gromacs/mdrun/minimize.cpp b/src/gromacs/mdrun/minimize.cpp index 35c7945e7e..4200b843f4 100644 --- a/src/gromacs/mdrun/minimize.cpp +++ b/src/gromacs/mdrun/minimize.cpp @@ -2697,7 +2697,7 @@ Integrator::do_nm() } else if (atom_index.size() < 1000) { - GMX_LOG(mdlog.warning).appendTextFormatted("Small system size (N=%d), using full Hessian format.", + GMX_LOG(mdlog.warning).appendTextFormatted("Small system size (N=%zu), using full Hessian format.", atom_index.size()); bSparse = FALSE; } diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 1fa6cfced3..b8533410ba 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -299,7 +299,7 @@ static void override_nsteps_cmdline(const gmx::MDLogger &mdlog, } else if (nsteps_cmdline < -2) { - gmx_fatal(FARGS, "Invalid nsteps value passed on the command line: %d", + gmx_fatal(FARGS, "Invalid nsteps value passed on the command line: %ld", nsteps_cmdline); } /* Do nothing if nsteps_cmdline == -2 */ diff --git a/src/gromacs/options/basicoptions.cpp b/src/gromacs/options/basicoptions.cpp index 17f6af248e..98b4f7ac8e 100644 --- a/src/gromacs/options/basicoptions.cpp +++ b/src/gromacs/options/basicoptions.cpp @@ -85,7 +85,7 @@ void expandVector(size_t length, std::vector *values) if (values->size() != 1) { GMX_THROW(gmx::InvalidInputError(gmx::formatString( - "Expected 1 or %d values, got %d", length, values->size()))); + "Expected 1 or %zu values, got %zu", length, values->size()))); } const ValueType &value = (*values)[0]; values->resize(length, value); diff --git a/src/gromacs/pbcutil/mshift.cpp b/src/gromacs/pbcutil/mshift.cpp index 4ff56f879c..e7949ce941 100644 --- a/src/gromacs/pbcutil/mshift.cpp +++ b/src/gromacs/pbcutil/mshift.cpp @@ -903,7 +903,7 @@ void mk_mshift(FILE *log, t_graph *g, int ePBC, default: mesg += " Either you have excessively large distances between atoms in bonded interactions or your system is exploding."; } - gmx_fatal(FARGS, mesg.c_str()); + gmx_fatal(FARGS, "%s", mesg.c_str()); } /* The most likely reason for arriving here is a periodic molecule. */ diff --git a/src/gromacs/pulling/pull.cpp b/src/gromacs/pulling/pull.cpp index 6d8f51217e..0f0532451a 100644 --- a/src/gromacs/pulling/pull.cpp +++ b/src/gromacs/pulling/pull.cpp @@ -1063,7 +1063,7 @@ static void do_constraint(struct pull_t *pull, t_pbc *pbc, if (dnorm2(r_ij[c]) == 0) { - gmx_fatal(FARGS, "Distance for pull coordinate %d is zero with constraint pulling, which is not allowed.", c + 1); + gmx_fatal(FARGS, "Distance for pull coordinate %lu is zero with constraint pulling, which is not allowed.", c + 1); } } @@ -1109,7 +1109,7 @@ static void do_constraint(struct pull_t *pull, t_pbc *pbc, case epullgDIST: if (pcrd->value_ref <= 0) { - gmx_fatal(FARGS, "The pull constraint reference distance for group %d is <= 0 (%f)", c, pcrd->value_ref); + gmx_fatal(FARGS, "The pull constraint reference distance for group %zu is <= 0 (%f)", c, pcrd->value_ref); } { diff --git a/src/gromacs/selection/selmethod.cpp b/src/gromacs/selection/selmethod.cpp index c1f0d4d0bd..218e8d2150 100644 --- a/src/gromacs/selection/selmethod.cpp +++ b/src/gromacs/selection/selmethod.cpp @@ -601,7 +601,7 @@ gmx_ana_selmethod_register(gmx::SelectionParserSymbolTable *symtab, } catch (const gmx::APIError &ex) { - report_error(stderr, name, ex.what()); + report_error(stderr, name, "%s", ex.what()); bOk = false; } } diff --git a/src/gromacs/tables/splineutil.cpp b/src/gromacs/tables/splineutil.cpp index 7565773a26..fc1f4941b7 100644 --- a/src/gromacs/tables/splineutil.cpp +++ b/src/gromacs/tables/splineutil.cpp @@ -103,7 +103,7 @@ throwUnlessDerivativeIsConsistentWithFunction(const std::function func } if (!isConsistent) { - GMX_THROW(InconsistentInputError(formatString("Derivative inconsistent with numerical vector for elements %d-%d", minFail+1, maxFail+1))); + GMX_THROW(InconsistentInputError(formatString("Derivative inconsistent with numerical vector for elements %lu-%lu", minFail+1, maxFail+1))); } } diff --git a/src/gromacs/taskassignment/reportgpuusage.cpp b/src/gromacs/taskassignment/reportgpuusage.cpp index 35d3e414c4..e3daa7ea41 100644 --- a/src/gromacs/taskassignment/reportgpuusage.cpp +++ b/src/gromacs/taskassignment/reportgpuusage.cpp @@ -125,7 +125,7 @@ reportGpuUsage(const MDLogger &mdlog, output += gmx::formatString("On host %s ", host); } output += gmx::formatString("%zu GPU%s %sselected for this run.\n" - "Mapping of GPU IDs to the %d GPU task%s in the %d rank%s on this node:\n %s\n", + "Mapping of GPU IDs to the %zu GPU task%s in the %zu rank%s on this node:\n %s\n", numGpusInUse, bPluralGpus ? "s" : "", userSetGpuIds ? "user-" : "auto-", numGpuTasksOnThisNode, diff --git a/src/gromacs/taskassignment/resourcedivision.cpp b/src/gromacs/taskassignment/resourcedivision.cpp index a16deffb45..ab1436759a 100644 --- a/src/gromacs/taskassignment/resourcedivision.cpp +++ b/src/gromacs/taskassignment/resourcedivision.cpp @@ -942,7 +942,7 @@ void checkHardwareOversubscription(int numThreadsOnT * TODO: When we have a proper parallel logging framework, * the framework should add the rank and node numbers. */ - GMX_LOG(mdlog.warning).asParagraph().appendTextFormatted(mesg.c_str()); + GMX_LOG(mdlog.warning).asParagraph().appendTextFormatted("%s", mesg.c_str()); } } diff --git a/src/gromacs/tools/dump.cpp b/src/gromacs/tools/dump.cpp index f5bec85997..fcfc808365 100644 --- a/src/gromacs/tools/dump.cpp +++ b/src/gromacs/tools/dump.cpp @@ -187,7 +187,7 @@ static void list_top(const char *fn) status = cpp_open_file(fn, &handle, cppopts); if (status != 0) { - gmx_fatal(FARGS, cpp_error(&handle, status)); + gmx_fatal(FARGS, "%s", cpp_error(&handle, status)); } do { @@ -197,7 +197,7 @@ static void list_top(const char *fn) { if (status != eCPP_OK) { - gmx_fatal(FARGS, cpp_error(&handle, status)); + gmx_fatal(FARGS, "%s", cpp_error(&handle, status)); } else { @@ -209,7 +209,7 @@ static void list_top(const char *fn) status = cpp_close_file(&handle); if (status != eCPP_OK) { - gmx_fatal(FARGS, cpp_error(&handle, status)); + gmx_fatal(FARGS, "%s", cpp_error(&handle, status)); } } diff --git a/src/gromacs/topology/symtab.cpp b/src/gromacs/topology/symtab.cpp index 5a9f65ca81..0798390d26 100644 --- a/src/gromacs/topology/symtab.cpp +++ b/src/gromacs/topology/symtab.cpp @@ -66,7 +66,7 @@ static char *trim_string(const char *s, char *out, int maxlen) if (strlen(s) > (size_t)(maxlen-1)) { - gmx_fatal(FARGS, "String '%s' (%d) is longer than buffer (%d).\n", + gmx_fatal(FARGS, "String '%s' (%zu) is longer than buffer (%d).\n", s, strlen(s), maxlen-1); } diff --git a/src/gromacs/utility/smalloc.cpp b/src/gromacs/utility/smalloc.cpp index e352fe5ab9..ca77fdd992 100644 --- a/src/gromacs/utility/smalloc.cpp +++ b/src/gromacs/utility/smalloc.cpp @@ -201,7 +201,7 @@ void *save_malloc_aligned(const char *name, const char *file, int line, if (alignment > alignmentSize) { gmx_fatal(errno, __FILE__, __LINE__, - "Cannot allocate aligned memory with alignment > %u bytes\n(called from file %s, line %d)", alignmentSize, file, line); + "Cannot allocate aligned memory with alignment > %zu bytes\n(called from file %s, line %d)", alignmentSize, file, line); } @@ -225,7 +225,7 @@ void *save_malloc_aligned(const char *name, const char *file, int line, if (p == nullptr) { gmx_fatal(errno, __FILE__, __LINE__, - "Not enough memory. Failed to allocate %u aligned elements of size %u for %s\n(called from file %s, line %d)", nelem, elsize, name, file, line); + "Not enough memory. Failed to allocate %zu aligned elements of size %zu for %s\n(called from file %s, line %d)", nelem, elsize, name, file, line); } } return p;