From: Roland Schulz Date: Fri, 13 Jul 2018 04:18:58 +0000 (-0700) Subject: Warn for type mismatch for gmx printf like functions 2/3 X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=6eb662a18d46dbd260365f643002fdc2dce62f21;p=alexxy%2Fgromacs.git Warn for type mismatch for gmx printf like functions 2/3 Most manual fixes. Inclduing those with missing/extra arguments. Related #2570 Change-Id: I2046d323dad6420e61f47918b12aa538f4a6d4a0 --- diff --git a/src/gromacs/awh/biasstate.cpp b/src/gromacs/awh/biasstate.cpp index 4bf7bf3263..c45f8f19b5 100644 --- a/src/gromacs/awh/biasstate.cpp +++ b/src/gromacs/awh/biasstate.cpp @@ -1523,9 +1523,9 @@ static void readUserPmfAndTargetDistribution(const std::vector &dimPa if (numColumns < numColumnsMin) { std::string mesg = - gmx::formatString("The number of columns in %s (%s) should be at least %d." + gmx::formatString("The number of columns in %s should be at least %d." "\n\n%s", - filename.c_str(), correctFormatMessage.c_str()); + filename.c_str(), numColumnsMin, correctFormatMessage.c_str()); GMX_THROW(InvalidInputError(mesg)); } diff --git a/src/gromacs/awh/read-params.cpp b/src/gromacs/awh/read-params.cpp index 63e4fc0696..353ec24350 100644 --- a/src/gromacs/awh/read-params.cpp +++ b/src/gromacs/awh/read-params.cpp @@ -271,7 +271,7 @@ static void read_bias_params(std::vector *inp, AwhBiasParams *awhBias awhBiasParams->errorInitial = get_ereal(inp, opt, 10, wi); if (awhBiasParams->errorInitial <= 0) { - gmx_fatal(FARGS, "%s (%d) needs to be > 0.", opt); + gmx_fatal(FARGS, "%s needs to be > 0.", opt); } if (bComment) @@ -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%f-dim%d-end", + gmx_fatal(FARGS, "For the non-periodic pull coordinates awh%d-dim%d-start (%f) cannot be larger than awh%d-dim%d-end (%f)", k + 1, d + 1, origin, k + 1, d + 1, end); } diff --git a/src/gromacs/fileio/enxio.cpp b/src/gromacs/fileio/enxio.cpp index 78aaf2ae18..dc0a177c9f 100644 --- a/src/gromacs/fileio/enxio.cpp +++ b/src/gromacs/fileio/enxio.cpp @@ -505,7 +505,7 @@ static gmx_bool do_eheader(ener_file_t ef, int *file_version, t_enxframe *fr, } if (*bOK && *file_version > enx_version) { - gmx_fatal(FARGS, "reading tpx file (%s) version %d with version %d program", gmx_fio_getname(ef->fio), file_version, enx_version); + gmx_fatal(FARGS, "reading tpx file (%s) version %d with version %d program", gmx_fio_getname(ef->fio), *file_version, enx_version); } if (!gmx_fio_do_double(ef->fio, fr->t)) { diff --git a/src/gromacs/gmxana/dlist.cpp b/src/gromacs/gmxana/dlist.cpp index 0b09a2842b..6661f757f2 100644 --- a/src/gromacs/gmxana/dlist.cpp +++ b/src/gromacs/gmxana/dlist.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2016,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. @@ -229,7 +229,7 @@ t_dlist *mk_dlist(FILE *log, { gmx_fatal(FARGS, "Unknown residue %s when searching for residue type.\n" "Maybe you need to add a custom residue in residuetypes.dat.", - thisres, __FILE__, __LINE__); + thisres); } sprintf(dl[nl].name, "%s%d", thisres, ires+r0); diff --git a/src/gromacs/gmxana/gmx_bar.cpp b/src/gromacs/gmxana/gmx_bar.cpp index 76bd921c05..446d265522 100644 --- a/src/gromacs/gmxana/gmx_bar.cpp +++ b/src/gromacs/gmxana/gmx_bar.cpp @@ -3316,7 +3316,7 @@ static void read_barsim_edr(const char *fn, real *temp, sim_data_t *sd) if (!lambda_vec_same(&start_lambda, native_lambda) ) { gmx_fatal(FARGS, "Native lambda not constant in file %s: started at %f, and becomes %f at time %f", - fn, native_lambda->val, start_lambda.val, start_time); + fn, native_lambda->val[0], start_lambda.val[0], start_time); } /* check the number of samples against the previous number */ if ( ((nblocks_raw+nblocks_hist) != nsamples) || (nlam != 1 ) ) diff --git a/src/gromacs/gmxana/gmx_densorder.cpp b/src/gromacs/gmxana/gmx_densorder.cpp index 94997770cc..cdc9d9b1dc 100644 --- a/src/gromacs/gmxana/gmx_densorder.cpp +++ b/src/gromacs/gmxana/gmx_densorder.cpp @@ -775,7 +775,7 @@ int gmx_densorder(int argc, char *argv[]) gmx::ArrayRef graphFiles = opt2fns("-og", NFILE, fnm); if (graphFiles.size() != 2) { - gmx_fatal(FARGS, "No or not correct number (2) of output-files: %zu", graphFiles.size()); + gmx_fatal(FARGS, "No or not correct number (2) of output-files: %td", graphFiles.size()); } writesurftoxpms(surf1, surf2, tblock, xslices, yslices, zslices, binw, binwz, graphFiles, zslices); } @@ -790,7 +790,7 @@ int gmx_densorder(int argc, char *argv[]) gmx::ArrayRef rawFiles = opt2fns("-or", NFILE, fnm); if (rawFiles.size() != 2) { - gmx_fatal(FARGS, "No or not correct number (2) of output-files: %zu", rawFiles.size()); + gmx_fatal(FARGS, "No or not correct number (2) of output-files: %td", rawFiles.size()); } writeraw(surf1, surf2, tblock, xslices, yslices, rawFiles, oenv); } @@ -802,7 +802,7 @@ int gmx_densorder(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-file-series: %zu", + gmx_fatal(FARGS, "No or not correct number (2) of output-file-series: %td", spectra.size()); } powerspectavg_intf(surf1, surf2, tblock, xslices, yslices, spectra); diff --git a/src/gromacs/gmxana/gmx_do_dssp.cpp b/src/gromacs/gmxana/gmx_do_dssp.cpp index cdf2085212..cc8c87c692 100644 --- a/src/gromacs/gmxana/gmx_do_dssp.cpp +++ b/src/gromacs/gmxana/gmx_do_dssp.cpp @@ -665,7 +665,7 @@ int gmx_do_dssp(int argc, char *argv[]) if (0 != system(dssp)) { - gmx_fatal(FARGS, "Failed to execute command: %s\n", + gmx_fatal(FARGS, "Failed to execute command: %s\n" "Try specifying your dssp version with the -ver option.", dssp); } diff --git a/src/gromacs/gmxana/gmx_nmr.cpp b/src/gromacs/gmxana/gmx_nmr.cpp index 4bf48a4eef..b8f15180e4 100644 --- a/src/gromacs/gmxana/gmx_nmr.cpp +++ b/src/gromacs/gmxana/gmx_nmr.cpp @@ -786,7 +786,7 @@ int gmx_nmr(int argc, char *argv[]) if (blk->sub[0].nr != nor) { - gmx_fatal(FARGS, "Number of orientation restraints in energy file (%d) does not match with the topology (%d)", blk->sub[0].nr); + gmx_fatal(FARGS, "Number of orientation restraints in energy file (%d) does not match with the topology (%d)", blk->sub[0].nr, nor); } if (bORA || bODA) { diff --git a/src/gromacs/gmxana/gmx_trjcat.cpp b/src/gromacs/gmxana/gmx_trjcat.cpp index 8521164281..9d5ed554e2 100644 --- a/src/gromacs/gmxana/gmx_trjcat.cpp +++ b/src/gromacs/gmxana/gmx_trjcat.cpp @@ -552,7 +552,7 @@ int gmx_trjcat(int argc, char *argv[]) if (bDeMux && static_cast(inFiles.size()) != nset) { - gmx_fatal(FARGS, "You have specified %zu files and %d entries in the demux table", inFiles.size(), nset); + gmx_fatal(FARGS, "You have specified %td files and %d entries in the demux table", inFiles.size(), nset); } ftpin = fn2ftp(inFiles[0].c_str()); @@ -581,7 +581,7 @@ int gmx_trjcat(int argc, char *argv[]) } else if (bDeMux && static_cast(outFiles.size()) != nset && outFiles.size() != 1) { - gmx_fatal(FARGS, "Number of output files should be 1 or %d (#input files), not %zu", nset, outFiles.size()); + gmx_fatal(FARGS, "Number of output files should be 1 or %d (#input files), not %td", nset, outFiles.size()); } if (bDeMux) { diff --git a/src/gromacs/gmxana/gmx_trjorder.cpp b/src/gromacs/gmxana/gmx_trjorder.cpp index f34e6077c6..698107ca12 100644 --- a/src/gromacs/gmxana/gmx_trjorder.cpp +++ b/src/gromacs/gmxana/gmx_trjorder.cpp @@ -189,7 +189,7 @@ int gmx_trjorder(int argc, char *argv[]) { if (index[i][j] > natoms) { - gmx_fatal(FARGS, "An atom number in group %s is larger than the number of atoms in the trajectory"); + gmx_fatal(FARGS, "An atom number in group %s is larger than the number of atoms in the trajectory", grpname[i]); } } } diff --git a/src/gromacs/gmxana/gmx_wham.cpp b/src/gromacs/gmxana/gmx_wham.cpp index 395d9e96de..a47e10c4e3 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 %d are not equally spaced.\n", ny, fn); + gmx_fatal(FARGS, "z-values in %s are not equally spaced.\n", fn); } } snew(opt->tabY, nl); @@ -1871,7 +1871,7 @@ static FILE *open_pdo_pipe(const char *fn, t_UmbrellaOptions *opt, gmx_bool *bPi { gmx_fatal(FARGS, "Cannot find executable gunzip in /bin or /usr/bin.\n" "You may want to define the path to gunzip " - "with the environment variable GMX_PATH_GZIP.", gunzip); + "with the environment variable GMX_PATH_GZIP."); } } else @@ -2126,7 +2126,7 @@ static void read_tpr_header(const char *fn, t_UmbrellaHeader* header, t_Umbrella } if (header->pcrd[i].k <= 0.0) { - gmx_fatal(FARGS, "%s: Pull coordinate %d has force constant of of %g in %s.\n" + gmx_fatal(FARGS, "%s: Pull coordinate %d has force constant of of %g.\n" "That doesn't seem to be an Umbrella tpr.\n", fn, i+1, header->pcrd[i].k); } diff --git a/src/gromacs/gmxpreprocess/pdb2gmx.cpp b/src/gromacs/gmxpreprocess/pdb2gmx.cpp index d331036628..87ec06ae80 100644 --- a/src/gromacs/gmxpreprocess/pdb2gmx.cpp +++ b/src/gromacs/gmxpreprocess/pdb2gmx.cpp @@ -249,7 +249,7 @@ static void read_rtprename(const char *fname, FILE *fp, { if (nc != 2 && nc != 5) { - gmx_fatal(FARGS, "Residue renaming database '%s' has %d columns instead of %d, %d or %d", fname, ncol, 2, 5); + gmx_fatal(FARGS, "Residue renaming database '%s' has %d columns instead of %d or %d", fname, ncol, 2, 5); } ncol = nc; } @@ -1586,8 +1586,7 @@ int gmx_pdb2gmx(int argc, char *argv[]) bVsiteAromatics = TRUE; break; default: - gmx_fatal(FARGS, "DEATH HORROR in $s (%s): vsitestr[0]='%d'", - __FILE__, __LINE__, vsitestr[0]); + gmx_fatal(FARGS, "Internal inconsistency: vsitestr[0]='%s'", vsitestr[0]); } /* end switch */ /* Open the symbol table */ diff --git a/src/gromacs/hardware/detecthardware.cpp b/src/gromacs/hardware/detecthardware.cpp index 81a8f98d73..aea9a1a3e6 100644 --- a/src/gromacs/hardware/detecthardware.cpp +++ b/src/gromacs/hardware/detecthardware.cpp @@ -144,7 +144,7 @@ static void gmx_detect_gpus(const gmx::MDLogger &mdlog, { GMX_LOG(mdlog.info).asParagraph().appendTextFormatted( "NOTE: Detection of GPUs failed. The API reported:\n" - " %s\n", + " %s\n" " GROMACS cannot run tasks on a GPU.", errorMessage.c_str()); } diff --git a/src/gromacs/imd/imd.cpp b/src/gromacs/imd/imd.cpp index 8c2af328dd..13d54d66bf 100644 --- a/src/gromacs/imd/imd.cpp +++ b/src/gromacs/imd/imd.cpp @@ -534,7 +534,7 @@ static void imd_prepare_master_socket(t_gmx_IMD_setup *IMDsetup) if (imdsock_getport(IMDsetup->socket, &IMDsetup->port)) { - gmx_fatal(FARGS, "%s Could not determine port number.\n", IMDstr, ret); + gmx_fatal(FARGS, "%s Could not determine port number.\n", IMDstr); } fprintf(stderr, "%s Listening for IMD connection on port %d.\n", IMDstr, IMDsetup->port); diff --git a/src/gromacs/mdlib/mdebin.cpp b/src/gromacs/mdlib/mdebin.cpp index ddd39c3925..b8efb73d58 100644 --- a/src/gromacs/mdlib/mdebin.cpp +++ b/src/gromacs/mdlib/mdebin.cpp @@ -1567,7 +1567,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 (%zu or %zu).", + gmx_fatal(FARGS, "Mismatch between number of energies in run input (%u) and checkpoint file (%zu or %zu).", nener, enerhist->ener_sum.size(), enerhist->ener_sum_sim.size()); } diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index 03913bf416..042bb6ceab 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -333,7 +333,7 @@ static void print_large_forces(FILE *fp, const rvec *f) { real force2Tolerance = gmx::square(forceTolerance); - std::uintmax_t numNonFinite = 0; + gmx::index numNonFinite = 0; for (int i = 0; i < md->homenr; i++) { real force2 = norm2(f[i]); @@ -355,7 +355,7 @@ static void print_large_forces(FILE *fp, * the printing on other ranks. But we can only avoid that with * an expensive MPI barrier that we would need at each step. */ - gmx_fatal(FARGS, "At step %" PRId64 " detected non-finite forces on %ju atoms", step, numNonFinite); + gmx_fatal(FARGS, "At step %" PRId64 " detected non-finite forces on %td atoms", step, numNonFinite); } } diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 82c96097f4..7337df0886 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -679,16 +679,14 @@ int Mdrunner::mdrunner() gmx_fatal(FARGS, "The -dd or -npme option request a parallel simulation, " #if !GMX_MPI - "but %s was compiled without threads or MPI enabled" + "but %s was compiled without threads or MPI enabled", output_env_get_program_display_name(oenv)); #else #if GMX_THREAD_MPI - "but the number of MPI-threads (option -ntmpi) is not set or is 1" + "but the number of MPI-threads (option -ntmpi) is not set or is 1"); #else - "but %s was not started through mpirun/mpiexec or only one rank was requested through mpirun/mpiexec" + "but %s was not started through mpirun/mpiexec or only one rank was requested through mpirun/mpiexec", output_env_get_program_display_name(oenv)); #endif #endif - , output_env_get_program_display_name(oenv) - ); } if (doRerun && diff --git a/src/gromacs/pulling/pull_rotation.cpp b/src/gromacs/pulling/pull_rotation.cpp index 76badaeda5..f9fd3abeef 100644 --- a/src/gromacs/pulling/pull_rotation.cpp +++ b/src/gromacs/pulling/pull_rotation.cpp @@ -644,7 +644,7 @@ static double calc_beta_max(real min_gaussian, real slab_dist) } if (min_gaussian <= 0) { - gmx_fatal(FARGS, "Cutoff value for Gaussian must be > 0. (You requested %f)"); + gmx_fatal(FARGS, "Cutoff value for Gaussian must be > 0. (You requested %f)", min_gaussian); } /* Define the sigma value */ diff --git a/src/gromacs/utility/smalloc.cpp b/src/gromacs/utility/smalloc.cpp index f329a2c8ec..bf5015c006 100644 --- a/src/gromacs/utility/smalloc.cpp +++ b/src/gromacs/utility/smalloc.cpp @@ -165,9 +165,9 @@ void *save_realloc(const char *name, const char *file, int line, void *ptr, if (p == nullptr) { gmx_fatal(errno, __FILE__, __LINE__, - "Not enough memory. Failed to realloc %" PRId64 " bytes for %s, %s=%x\n" + "Not enough memory. Failed to realloc %zu bytes for %s, %s=%p\n" "(called from file %s, line %d)", - static_cast(size), name, name, ptr, file, line); + size, name, name, ptr, file, line); } } return p;