Fixes have been missing from previous fixes.
Refs #3897
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2018,2019,2021, 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.
inline static bool bitmask_is_disjoint(gmx_bitmask_t a, gmx_bitmask_t b)
{
- int i;
bool r = true;
- for (i = 0; i < BITMASK_ALEN; i++)
+ for (int i = 0; i < BITMASK_ALEN; i++)
{
r = r && ((a[i] & b[i]) == 0U);
}
inline static bool bitmask_is_equal(gmx_bitmask_t a, gmx_bitmask_t b)
{
- int i;
bool r = true;
- for (i = 0; i < BITMASK_ALEN; i++)
+ for (int i = 0; i < BITMASK_ALEN; i++)
{
r = r && (a[i] == b[i]);
}
inline static bool bitmask_is_zero(gmx_bitmask_t m)
{
- int i;
bool r = true;
- for (i = 0; i < BITMASK_ALEN; i++)
+ for (int i = 0; i < BITMASK_ALEN; i++)
{
r = r && (m[i] == 0U);
}
inline static void bitmask_union(gmx_bitmask_t* a, gmx_bitmask_t b)
{
- int i;
- for (i = 0; i < BITMASK_ALEN; i++)
+ for (int i = 0; i < BITMASK_ALEN; i++)
{
(*a)[i] |= b[i];
}
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
int continuing(char* s)
{
- int sl;
assert(s);
rtrim(s);
- sl = strlen(s);
+ int sl = strlen(s);
if ((sl > 0) && (s[sl - 1] == CONTINUE))
{
s[sl - 1] = 0;
char* fgets2(char* line, int n, FILE* stream)
{
- char* c;
+ char* c = nullptr;
if (fgets(line, n, stream) == nullptr)
{
return nullptr;
void strip_comment(char* line)
{
- char* c;
+ char* c = nullptr;
if (!line)
{
void upstring(char* str)
{
- int i;
-
- for (i = 0; (i < static_cast<int>(strlen(str))); i++)
+ for (int i = 0; (i < static_cast<int>(strlen(str))); i++)
{
str[i] = toupper(str[i]);
}
void ltrim(char* str)
{
- int i, c;
-
if (nullptr == str)
{
return;
}
- c = 0;
+ int c = 0;
while (('\0' != str[c]) && isspace(str[c]))
{
c++;
}
if (c > 0)
{
- for (i = c; ('\0' != str[i]); i++)
+ int i = c;
+ for (; ('\0' != str[i]); i++)
{
str[i - c] = str[i];
}
void rtrim(char* str)
{
- int nul;
-
if (nullptr == str)
{
return;
}
- nul = strlen(str) - 1;
+ int nul = strlen(str) - 1;
while ((nul > 0) && ((str[nul] == ' ') || (str[nul] == '\t')))
{
str[nul] = '\0';
int gmx_strcasecmp_min(const char* str1, const char* str2)
{
- char ch1, ch2;
+ char ch1 = 0, ch2 = 0;
do
{
int gmx_strncasecmp_min(const char* str1, const char* str2, int n)
{
- char ch1, ch2;
- char *stri1, *stri2;
+ char ch1 = 0, ch2 = 0;
- stri1 = const_cast<char*>(str1);
- stri2 = const_cast<char*>(str2);
+ const char* stri1 = str1;
+ const char* stri2 = str2;
do
{
do
int gmx_strcasecmp(const char* str1, const char* str2)
{
- char ch1, ch2;
+ char ch1 = 0, ch2 = 0;
do
{
int gmx_strncasecmp(const char* str1, const char* str2, int n)
{
- char ch1, ch2;
+ char ch1 = 0, ch2 = 0;
if (n == 0)
{
char* gmx_strdup(const char* src)
{
- char* dest;
+ char* dest = nullptr;
auto length = strlen(src) + 1;
snew(dest, length);
char* gmx_strndup(const char* src, int n)
{
- int len;
- char* dest;
+ char* dest = nullptr;
- len = strlen(src);
+ int len = strlen(src);
if (len > n)
{
len = n;
unsigned int gmx_string_fullhash_func(const char* s, unsigned int hash_init)
{
- int c;
+ int c = 0;
while ((c = (*s++)) != '\0')
{
unsigned int gmx_string_hash_func(const char* s, unsigned int hash_init)
{
- int c;
+ int c = 0;
while ((c = toupper(*s++)) != '\0')
{
* since we have processed them above. */
if (*pattern == *str)
{
- int rc;
/* Match the suffix, and return if a match or an error */
- rc = gmx_wcmatch(pattern, str);
+ int rc = gmx_wcmatch(pattern, str);
if (rc != GMX_NO_WCMATCH)
{
return rc;
char* wrap_lines(const char* buf, int line_width, int indent, gmx_bool bIndentFirst)
{
- char* b2;
- int i, i0, i2, j, b2len, lspace = 0, l2space = 0;
- gmx_bool bFirst, bFitsOnLine;
+ int i = 0;
/* characters are copied from buf to b2 with possible spaces changed
* into newlines and extra space added for indentation.
* the current line (where it also won't fit, but looks better)
*/
- b2 = nullptr;
- b2len = strlen(buf) + 1 + indent;
+ char* b2 = nullptr;
+ int b2len = strlen(buf) + 1 + indent;
snew(b2, b2len);
- i0 = i2 = 0;
+ int i0 = 0;
+ int i2 = 0;
if (bIndentFirst)
{
for (i2 = 0; (i2 < indent); i2++)
b2[i2] = ' ';
}
}
- bFirst = TRUE;
+ bool bFirst = true;
do
{
- l2space = -1;
+ int lspace = 0;
+ int l2space = -1;
/* find the last space before end of line */
for (i = i0; ((i - i0 < line_width) || (l2space == -1)) && (buf[i]); i++)
{
b2len += indent;
srenew(b2, b2len);
/* add indentation after the newline */
- for (j = 0; (j < indent); j++)
+ for (int j = 0; (j < indent); j++)
{
b2[i2++] = ' ';
}
if (buf[i])
{
/* check if one word does not fit on the line */
- bFitsOnLine = (i - i0 <= line_width);
+ bool bFitsOnLine = (i - i0 <= line_width);
/* reset line counters to just after the space */
i0 = lspace + 1;
i2 = l2space + 1;
}
b2len += indent;
srenew(b2, b2len);
- for (j = 0; (j < indent); j++)
+ for (int j = 0; (j < indent); j++)
{
b2[i2++] = ' ';
}
int gmx_ffclose(FILE* fp)
{
- t_pstack *ps = nullptr, *tmp = nullptr;
- int ret = 0;
+ int ret = 0;
Lock pstackLock(pstack_mutex);
- ps = pstack;
+ t_pstack* ps = pstack;
if (ps == nullptr)
{
if (fp != nullptr)
{
ret = pclose(ps->prev->fp);
}
- tmp = ps->prev;
- ps->prev = ps->prev->prev;
+ t_pstack* tmp = ps->prev;
+ ps->prev = ps->prev->prev;
sfree(tmp);
}
else
gmx_bool gmx_fexist(const std::string& fname)
{
- FILE* test = nullptr;
-
if (fname.empty())
{
return FALSE;
}
- test = fopen(fname.c_str(), "r");
+ FILE* test = fopen(fname.c_str(), "r");
if (test == nullptr)
{
/*Windows doesn't allow fopen of directory - so we need to check this seperately */
FILE* gmx_ffopen(const std::string& file, const char* mode)
{
- FILE* ff = nullptr;
- gmx_bool bRead = 0;
- int bs = 0;
+ FILE* ff = nullptr;
if (file.empty())
{
make_backup(file);
}
- bRead = (mode[0] == 'r' && mode[1] != '+');
+ bool bRead = (mode[0] == 'r' && mode[1] != '+');
if (!bRead || gmx_fexist(file))
{
if ((ff = fopen(file.c_str(), mode)) == nullptr)
if (bUnbuffered || ((bufsize = getenv("GMX_LOG_BUFFER")) != nullptr))
{
/* Check whether to use completely unbuffered */
- if (bUnbuffered)
- {
- bs = 0;
- }
- else
- {
- bs = strtol(bufsize, nullptr, 10);
- }
+ const int bs = bUnbuffered ? 0 : strtol(bufsize, nullptr, 10);
if (bs <= 0)
{
setbuf(ff, nullptr);
* since windows doesnt support it we have to separate the cases.
* 20090307: mktemp deprecated, use iso c++ _mktemp instead.
*/
- int fd = 0;
#if GMX_NATIVE_WINDOWS
_mktemp(buf);
if (buf == NULL)
{
gmx_fatal(FARGS, "Error creating temporary file %s: %s", buf, strerror(errno));
}
- fd = 0;
+ int fd = 0;
#else
- fd = mkstemp(buf);
+ int fd = mkstemp(buf);
if (fd < 0)
{
while (!feof(in.get()))
{
- size_t nread = 0;
-
- nread = fread(buf.data(), sizeof(char), FILECOPY_BUFSIZE, in.get());
+ size_t nread = fread(buf.data(), sizeof(char), FILECOPY_BUFSIZE, in.get());
if (nread > 0)
{
size_t ret = 0;
int rc = 0;
{
- int fn = 0;
-
/* get the file number */
#if HAVE_FILENO
- fn = fileno(fp);
+ int fn = fileno(fp);
#elif HAVE__FILENO
- fn = _fileno(fp);
+ int fn = _fileno(fp);
#else
GMX_UNUSED_VALUE(fp);
- fn = -1;
+ int fn = -1;
#endif
/* do the actual fsync */
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020,2021, 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.
}
void doString(std::string* value)
{
- uint64_t size;
+ uint64_t size = 0;
doValue<uint64_t>(&size);
*value = std::string(&buffer_[pos_], size);
pos_ += size;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2015,2017,2018,2019,2021, 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.
int int64_to_int(int64_t step, const char* warn)
{
- int i;
-
- i = static_cast<int>(step);
+ int i = static_cast<int>(step);
if (warn != nullptr && (static_cast<int64_t>(i) != step))
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020,2021, 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.
}
}
- bool areSimpleValuesOfSameTypeEqual(const KeyValueTreeValue& value1, const KeyValueTreeValue& value2)
+ bool areSimpleValuesOfSameTypeEqual(const KeyValueTreeValue& value1, const KeyValueTreeValue& value2) const
{
GMX_ASSERT(value1.type() == value2.type(), "Caller should ensure that types are equal");
if (value1.isType<bool>())
#include "gromacs/utility/iserializer.h"
#include "gromacs/utility/keyvaluetree.h"
#include "gromacs/utility/keyvaluetreebuilder.h"
+#include "math.h"
namespace gmx
{
}
static void deserializeObject(KeyValueTreeObjectBuilder* builder, ISerializer* serializer)
{
- int count;
+ int count = 0;
std::string key;
serializer->doInt(&count);
for (int i = 0; i < count; ++i)
static void deserialize(KeyValueTreeValueBuilder* value, ISerializer* serializer)
{
KeyValueTreeArrayBuilder builder(value->createArray());
- int count;
+ int count = 0;
serializer->doInt(&count);
for (int i = 0; i < count; ++i)
{
static void serialize(bool value, ISerializer* serializer) { serializer->doBool(&value); }
static void deserialize(KeyValueTreeValueBuilder* builder, ISerializer* serializer)
{
- bool value;
+ bool value = false;
serializer->doBool(&value);
builder->setValue<bool>(value);
}
static void serialize(int value, ISerializer* serializer) { serializer->doInt(&value); }
static void deserialize(KeyValueTreeValueBuilder* builder, ISerializer* serializer)
{
- int value;
+ int value = 0;
serializer->doInt(&value);
builder->setValue<int>(value);
}
static void serialize(int64_t value, ISerializer* serializer) { serializer->doInt64(&value); }
static void deserialize(KeyValueTreeValueBuilder* builder, ISerializer* serializer)
{
- int64_t value;
+ int64_t value = 0;
serializer->doInt64(&value);
builder->setValue<int64_t>(value);
}
static void serialize(float value, ISerializer* serializer) { serializer->doFloat(&value); }
static void deserialize(KeyValueTreeValueBuilder* builder, ISerializer* serializer)
{
- float value;
+ float value = 0;
serializer->doFloat(&value);
builder->setValue<float>(value);
}
static void serialize(double value, ISerializer* serializer) { serializer->doDouble(&value); }
static void deserialize(KeyValueTreeValueBuilder* builder, ISerializer* serializer)
{
- double value;
+ double value = 0;
serializer->doDouble(&value);
builder->setValue<double>(value);
}
KeyValueTreeValue ValueSerializer::deserialize(ISerializer* serializer)
{
- unsigned char typeTag;
+ unsigned char typeTag = 0;
serializer->doUChar(&typeTag);
auto iter = s_deserializers.find(typeTag);
GMX_RELEASE_ASSERT(iter != s_deserializers.end(), "Unknown type tag for deserializization");
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2021, 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.
void niceHeader(TextWriter* writer, const char* fn, char commentChar)
{
- int uid;
char userbuf[256];
char hostbuf[256];
writer->writeLine(formatString("%c", commentChar));
writer->writeLine(formatString("%c\tFile '%s' was generated", commentChar, fn ? fn : "unknown"));
- uid = gmx_getuid();
+ int uid = gmx_getuid();
gmx_getusername(userbuf, 256);
gmx_gethostname(hostbuf, 256);
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2011-2018, The GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
void Path::splitPathEnvironment(const std::string& pathEnv, std::vector<std::string>* result)
{
- size_t prevPos = 0;
- size_t separator;
+ size_t prevPos = 0;
+ size_t separator = 0;
do
{
separator = pathEnv.find(cPathSeparator, prevPos);
std::string result(path);
#if !GMX_NATIVE_WINDOWS
char buf[GMX_PATH_MAX];
- int length;
+ int length = 0;
while ((length = readlink(result.c_str(), buf, sizeof(buf) - 1)) > 0)
{
buf[length] = '\0';
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2021, 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.
PhysicalNodeCommunicator::PhysicalNodeCommunicator(MPI_Comm world, int physicalNodeId)
{
#if GMX_MPI
- int isInitialized;
+ int isInitialized = 0;
MPI_Initialized(&isInitialized);
if (isInitialized)
{
- int sizeOfWorld;
+ int sizeOfWorld = 0;
MPI_Comm_size(world, &sizeOfWorld);
if (sizeOfWorld > 1)
{
- int rankWithinWorld;
+ int rankWithinWorld = 0;
MPI_Comm_rank(world, &rankWithinWorld);
MPI_Comm_split(world, physicalNodeId, rankWithinWorld, &comm_);
auto ptr = MPI_Comm_ptr(&comm_);
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
const char* pages;
} t_citerec;
+static constexpr int sc_lineWidth = 79;
+
void please_cite(FILE* fp, const char* key)
{
static const t_citerec citedb[] = {
};
#define NSTR static_cast<int>(asize(citedb))
- int index;
- char* author;
- char* title;
-#define LINE_WIDTH 79
-
if (fp == nullptr)
{
return;
}
- for (index = 0; index < NSTR && (strcmp(citedb[index].key, key) != 0); index++) {}
+ int index = 0;
+ for (; index < NSTR && (strcmp(citedb[index].key, key) != 0); index++) {}
fprintf(fp, "\n++++ PLEASE READ AND CITE THE FOLLOWING REFERENCE ++++\n");
if (index < NSTR)
{
/* Insert newlines */
- author = wrap_lines(citedb[index].author, LINE_WIDTH, 0, FALSE);
- title = wrap_lines(citedb[index].title, LINE_WIDTH, 0, FALSE);
+ char* author = wrap_lines(citedb[index].author, sc_lineWidth, 0, FALSE);
+ char* title = wrap_lines(citedb[index].title, sc_lineWidth, 0, FALSE);
fprintf(fp,
"%s\n%s\n%s %d (%d) pp. %s\n",
author,
return;
}
gmx::TextLineWrapper wrapper;
- wrapper.settings().setLineLength(LINE_WIDTH);
+ wrapper.settings().setLineLength(sc_lineWidth);
wrapper.settings().setFirstLineIndent(0);
const std::string doiString = wrapper.wrapToString(gmxDOI());
void* save_malloc(const char* name, const char* file, int line, size_t size)
{
- void* p;
+ void* p = nullptr;
- p = nullptr;
if (size == 0)
{
p = nullptr;
void* save_calloc(const char* name, const char* file, int line, size_t nelem, size_t elsize)
{
- void* p;
+ void* p = nullptr;
- p = nullptr;
if ((nelem == 0) || (elsize == 0))
{
p = nullptr;
void* save_realloc(const char* name, const char* file, int line, void* ptr, size_t nelem, size_t elsize)
{
- void* p;
+ void* p = nullptr;
size_t size = nelem * elsize;
- p = nullptr;
if (size == 0)
{
save_free(name, file, line, ptr);
* the necessary alignment. */
void* save_malloc_aligned(const char* name, const char* file, int line, size_t nelem, size_t elsize, size_t alignment)
{
- void* p;
+ void* p = nullptr;
if (alignment == 0)
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2016,2018,2019,2021, 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.
int intFromString(const char* str)
{
- errno = 0;
- char* endptr;
- const long int value = std::strtol(str, &endptr, 10);
+ errno = 0;
+ char* endptr = nullptr;
+ const long int value = std::strtol(str, &endptr, 10);
if (errno == ERANGE || value < std::numeric_limits<int>::min()
|| value > std::numeric_limits<int>::max())
{
int64_t int64FromString(const char* str)
{
- errno = 0;
- char* endptr;
- const int64_t value = str_to_int64_t(str, &endptr);
+ errno = 0;
+ char* endptr = nullptr;
+ const int64_t value = str_to_int64_t(str, &endptr);
if (errno == ERANGE)
{
GMX_THROW(InvalidInputError("Invalid value: '" + std::string(str)
float floatFromString(const char* str)
{
- errno = 0;
- char* endptr;
- const double value = std::strtod(str, &endptr);
+ errno = 0;
+ char* endptr = nullptr;
+ const double value = std::strtod(str, &endptr);
if (errno == ERANGE || value < -std::numeric_limits<float>::max()
|| value > std::numeric_limits<float>::max())
{
double doubleFromString(const char* str)
{
- errno = 0;
- char* endptr;
- const double value = std::strtod(str, &endptr);
+ errno = 0;
+ char* endptr = nullptr;
+ const double value = std::strtod(str, &endptr);
if (errno == ERANGE)
{
GMX_THROW(InvalidInputError("Invalid value: '" + std::string(str)
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
gmx_bool get_a_line(FILE* fp, char line[], int n)
{
- char* line0;
- char* dum;
+ char* line0 = nullptr;
+ char* dum = nullptr;
snew(line0, n + 1);
int search_str(int nstr, char** str, char* key)
{
- int i;
-
/* Linear search */
- for (i = 0; (i < nstr); i++)
+ for (int i = 0; (i < nstr); i++)
{
if (gmx_strcasecmp(str[i], key) == 0)
{
static int fget_lines(FILE* in, const char* db, char*** strings)
{
- char** ptr;
+ char** ptr = nullptr;
char buf[STRLEN];
- int i, nstr;
- char* pret;
+ int nstr = 0;
- pret = fgets(buf, STRLEN, in);
+ char* pret = fgets(buf, STRLEN, in);
if (pret == nullptr || sscanf(buf, "%d", &nstr) != 1)
{
gmx_warning("File is empty");
return 0;
}
snew(ptr, nstr);
- for (i = 0; (i < nstr); i++)
+ for (int i = 0; (i < nstr); i++)
{
if (fgets2(buf, STRLEN, in) == nullptr)
{
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2011-2018, The GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
std::vector<std::string> splitDelimitedString(const std::string& str, char delim)
{
std::vector<std::string> result;
- size_t currPos = 0;
- const size_t len = str.length();
+ const size_t len = str.length();
if (len > 0)
{
- size_t nextDelim;
+ size_t nextDelim = 0;
+ size_t currPos = 0;
do
{
nextDelim = str.find(delim, currPos);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2018,2019,2021, 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.
BITMASK_TEST_P(SetAndClear) //NOLINT(misc-definitions-in-headers)
{
- gmx_bitmask_t m;
+ gmx_bitmask_t m; //NOLINT(cppcoreguidelines-init-variables)
int i = GetParam();
bitmask_clear(&m);
EXPECT_TRUE(bitmask_is_zero(m));
BITMASK_TEST_P(InitBit) //NOLINT(misc-definitions-in-headers)
{
- gmx_bitmask_t m1, m2;
+ gmx_bitmask_t m1, m2; //NOLINT(cppcoreguidelines-init-variables)
int i = GetParam();
bitmask_init_bit(&m1, i);
bitmask_clear(&m2);
BITMASK_TEST_P(InitLowBits) //NOLINT(misc-definitions-in-headers)
{
- gmx_bitmask_t m;
+ gmx_bitmask_t m; //NOLINT(cppcoreguidelines-init-variables)
int i = GetParam();
bitmask_init_low_bits(&m, i);
for (int j = 0; j < BITMASK_SIZE; j++)
BITMASK_TEST_P(Disjoint) //NOLINT(misc-definitions-in-headers)
{
- gmx_bitmask_t m1, m2;
+ gmx_bitmask_t m1, m2; //NOLINT(cppcoreguidelines-init-variables)
int i = GetParam();
bitmask_init_bit(&m1, i);
bitmask_init_bit(&m2, i);
BITMASK_TEST_P(Union) //NOLINT(misc-definitions-in-headers)
{
- gmx_bitmask_t m1, m2;
+ gmx_bitmask_t m1, m2; //NOLINT(cppcoreguidelines-init-variables)
int i = GetParam();
int j = (i + BITMASK_SIZE / 2) % BITMASK_SIZE;
bitmask_init_bit(&m1, i);
}
BITMASK_TEST_P(ToHex) //NOLINT(misc-definitions-in-headers)
{
- gmx_bitmask_t m;
+ gmx_bitmask_t m; //NOLINT(cppcoreguidelines-init-variables)
bitmask_clear(&m);
bitmask_set_bit(&m, BITMASK_SIZE - 1);
EXPECT_EQ(to_hex_string(m), "8" + std::string(BITMASK_SIZE / 4 - 1, '0'));
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
}
// Incrementing iterators works
- auto x = std::begin(fooStrings);
+ const auto* x = std::begin(fooStrings);
EXPECT_EQ(*x, "Bar");
++x;
EXPECT_EQ(*x, "Baz");
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
public:
void callback(EventA /*a*/) { notifiedEventA_ = true; }
- bool notifiedEventA() { return notifiedEventA_; }
+ bool notifiedEventA() const { return notifiedEventA_; }
private:
bool notifiedEventA_ = false;
public:
void callback(EventB* /* bPointer */) { notifiedEventB_ = true; }
- bool notifiedEventB() { return notifiedEventB_; }
+ bool notifiedEventB() const { return notifiedEventB_; }
private:
bool notifiedEventB_ = false;
void callback(EventA /* a */) { notifiedEventA_ = true; }
- bool notifiedEventB() { return notifiedEventB_; }
- bool notifiedEventA() { return notifiedEventA_; }
+ bool notifiedEventB() const { return notifiedEventB_; }
+ bool notifiedEventA() const { return notifiedEventA_; }
private:
bool notifiedEventB_ = false;
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
int pr_indent(FILE* fp, int n)
{
- int i;
-
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
fprintf(fp, " ");
}
void pr_reals(FILE* fp, int indent, const char* title, const real* vec, int n)
{
- int i;
-
if (available(fp, vec, indent, title))
{
pr_indent(fp, indent);
fprintf(fp, "%s:\t", title);
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
fprintf(fp, " %10g", vec[i]);
}
void pr_doubles(FILE* fp, int indent, const char* title, const double* vec, int n)
{
- int i;
-
if (available(fp, vec, indent, title))
{
pr_indent(fp, indent);
fprintf(fp, "%s:\t", title);
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
fprintf(fp, " %10g", vec[i]);
}
void pr_reals_of_dim(FILE* fp, int indent, const char* title, const real* vec, int n, int dim)
{
- int i, j;
const char* fshort = "%12.5e";
const char* flong = "%15.8e";
- const char* format;
-
- if (getenv("GMX_PRINT_LONGFORMAT") != nullptr)
- {
- format = flong;
- }
- else
- {
- format = fshort;
- }
+ const char* format = (getenv("GMX_PRINT_LONGFORMAT") != nullptr) ? flong : fshort;
if (available(fp, vec, indent, title))
{
indent = pr_title_nxn(fp, indent, title, n, dim);
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
pr_indent(fp, indent);
fprintf(fp, "%s[%5d]={", title, i);
- for (j = 0; j < dim; j++)
+ for (int j = 0; j < dim; j++)
{
if (j != 0)
{
void pr_strings(FILE* fp, int indent, const char* title, char*** nm, int n, gmx_bool bShowNumbers)
{
- int i;
-
if (available(fp, nm, indent, title))
{
indent = pr_title_n(fp, indent, title, n);
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
pr_indent(fp, indent);
fprintf(fp, "%s[%d]={name=\"%s\"}\n", title, bShowNumbers ? i : -1, *(nm[i]));