diff --git a/doc/src/Developer_utils.rst b/doc/src/Developer_utils.rst index 00a8b43a24..3165aaae75 100644 --- a/doc/src/Developer_utils.rst +++ b/doc/src/Developer_utils.rst @@ -15,8 +15,10 @@ I/O with status check The the first two functions are wrappers around the corresponding C library calls ``fgets()`` or ``fread()``. They will check if there were errors on reading or an unexpected end-of-file state was reached. -In that case, the functions will stop the calculation with an error -message, indicating the name of the problematic file, if possible. +In that case, the functions will stop with an error message, indicating +the name of the problematic file, if possible unless the *error* argument +is a NULL pointer. + The :cpp:func:`read_lines_from_file` function will read the requested number of lines of a maximum length into a buffer and will return 0 if successful or 1 if not. It also guarantees that all lines are diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index c93685c221..cefed6949d 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -2282,6 +2282,7 @@ Ntype ntypes Ntypes nucleotides +nullptr num numa numactl diff --git a/src/utils.h b/src/utils.h index 770c0b527a..21feef048b 100644 --- a/src/utils.h +++ b/src/utils.h @@ -55,7 +55,7 @@ namespace LAMMPS_NS { void logmesg(LAMMPS *lmp, const std::string &mesg); - /** return a string representing the current system error status + /** Return a string representing the current system error status * * This is a wrapper around calling strerror(errno). * @@ -63,8 +63,10 @@ namespace LAMMPS_NS { std::string getsyserror(); - /** safe wrapper around fgets() which aborts on errors - * or EOF and prints a suitable error message to help debugging + /** Safe wrapper around fgets() which aborts on errors + * or EOF and prints a suitable error message to help debugging. + * + * Use nullptr as the error parameter to avoid the abort on EOF or error. * * \param srcname name of the calling source file (from FLERR macro) * \param srcline line in the calling source file (from FLERR macro) @@ -72,13 +74,15 @@ namespace LAMMPS_NS { * \param size size of buffer s (max number of bytes read by fgets()) * \param fp file pointer used by fgets() * \param filename file name associated with fp (may be a null pointer; then LAMMPS will try to detect) - * \param error pointer to Error class instance (for abort) */ + * \param error pointer to Error class instance (for abort) or nullptr */ void sfgets(const char *srcname, int srcline, char *s, int size, FILE *fp, const char *filename, Error *error); - /** safe wrapper around fread() which aborts on errors - * or EOF and prints a suitable error message to help debugging + /** Safe wrapper around fread() which aborts on errors + * or EOF and prints a suitable error message to help debugging. + * + * Use nullptr as the error parameter to avoid the abort on EOF or error. * * \param srcname name of the calling source file (from FLERR macro) * \param srcline line in the calling source file (from FLERR macro) @@ -87,7 +91,7 @@ namespace LAMMPS_NS { * \param num number of data elements read by fread() * \param fp file pointer used by fread() * \param filename file name associated with fp (may be a null pointer; then LAMMPS will try to detect) - * \param error pointer to Error class instance (for abort) */ + * \param error pointer to Error class instance (for abort) or nullptr */ void sfread(const char *srcname, int srcline, void *s, size_t size, size_t num, FILE *fp, const char *filename, Error *error);