diff --git a/cfg/posix.cfg b/cfg/posix.cfg
index d335b30e3..381e8b071 100644
--- a/cfg/posix.cfg
+++ b/cfg/posix.cfg
@@ -19,6 +19,8 @@
+
+
0:
@@ -213,11 +215,13 @@
false
-
0:999999
+
+ Obsolescent function 'usleep' called. It is recommended to use 'nanosleep' or 'setitimer' instead.
+The obsolescent function 'usleep' is called. POSIX.1-2001 declares usleep() function obsolescent and POSIX.1-2008 removes it. It is recommended that new applications use the 'nanosleep' or 'setitimer' function.
@@ -277,23 +281,168 @@
false
+
+
+
+
+
+
+
+ false
+
+
+ Non reentrant function 'getrpcent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getrpcent_r'.
+
+
+
+ false
+
+
+
+
+
+
+ Non reentrant function 'getrpcbyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getrpcbyname_r'.
+
+
+
+ false
+
+ Non reentrant function 'getrpcbynumber' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getrpcbynumber_r'.
+
+
+
+ false
+
+
+ Non reentrant function 'getprotoent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getprotoent_r'.
+
+
+
+ false
+
+
+
+
+
+
+ Non reentrant function 'getprotobyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getprotobyname_r'.
+
+
+
+ false
+
+
+
+
+
+ Non reentrant function 'getprotobynumber' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getprotobynumber_r'.
+
+
+
+ false
+
+
+ Non reentrant function 'getservent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getservent_r'.
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+ Non reentrant function 'getservbyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getservbyname_r'.
+
+
+
+ false
+
+
+
+
+
+
+
+
+ Non reentrant function 'getservbyport' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getservbyport_r'.
+
+
+
+ false
+
+
+ Non reentrant function 'getnetent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getnetent_r'.
+
+
+
+ false
+
+
+
+
+
+
+ Non reentrant function 'getnetbyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getnetbyname_r'.
+
+
+
+ false
+
+
+
+
+
+
+
+
+ Non reentrant function 'getnetbyaddr' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getnetbyaddr_r'.
+
+
+
+ false
+
+
+ Non reentrant function 'gethostent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'gethostent_r'.
false
-
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+ Non reentrant function 'gethostbyname2' called. For threadsafe applications it is recommended to use the reentrant replacement function 'gethostbyname2_r'.
false
+
@@ -305,6 +454,7 @@
+
@@ -560,6 +710,7 @@
+
@@ -735,6 +886,7 @@
+
false
@@ -1166,14 +1318,16 @@
false
+
false
-
+
+
@@ -1384,8 +1538,9 @@
false
-
+
+
@@ -1433,21 +1588,38 @@
-
false
+
+ Non reentrant function 'getpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwent_r'.
-
- false
+ false
+
+ Non reentrant function 'getpwnam' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwnam_r'.
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+ Non reentrant function 'strtok' called. For threadsafe applications it is recommended to use the reentrant replacement function 'strtok_r'.
-
+
false
+
@@ -1470,11 +1642,12 @@
-
- false
+ false
+
+ Non reentrant function 'getpwuid' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwuid_r'.
@@ -1672,6 +1845,7 @@
+
@@ -1689,6 +1863,7 @@
+
@@ -1703,6 +1878,7 @@
+
@@ -1777,22 +1953,42 @@
false
-
+
-
-
+
+
false
+ Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.
+
+
+
+ false
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+ Non reentrant function 'readdir' called. For threadsafe applications it is recommended to use the reentrant replacement function 'readdir_r'.
+
false
@@ -1852,6 +2048,7 @@
+
@@ -1864,6 +2061,7 @@
+
@@ -1877,6 +2075,17 @@
+
+
+
+ false
+
+
+
+
+
+ Non reentrant function 'gmtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'gmtime_r'.
+
@@ -1926,6 +2135,380 @@
+
+
+ false
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ Obsolescent function 'makecontext' called. Applications are recommended to be rewritten to use POSIX threads.
+
+
+
+ false
+
+
+
+
+
+
+
+ Obsolescent function 'swapcontext' called. Applications are recommended to be rewritten to use POSIX threads.
+
+
+
+ false
+
+
+
+
+ Obsolescent function 'getcontext' called. Applications are recommended to be rewritten to use POSIX threads.
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+ Non reentrant function 'tempnam' called. For threadsafe applications it is recommended to use the reentrant replacement function 'tempnam_r'.
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+ Non reentrant function 'crypt' called. For threadsafe applications it is recommended to use the reentrant replacement function 'crypt_r'.
+
+
+
+ false
+
+
+
+
+
+ Non reentrant function 'ttyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'ttyname_r'.
+
+
+
+ false
+
+
+
+
+
+
+ Non reentrant function 'getspnam' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getspnam_r'.
+
+
+
+ false
+
+
+ Non reentrant function 'getspent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getspent_r'.
+
+
+
+ false
+
+
+
+
+
+
+ Non reentrant function 'fgetspent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'fgetspent_r'.
+
+
+
+ false
+
+
+
+
+
+
+ Non reentrant function 'sgetspent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'sgetspent_r'.
+
+
+
+ false
+
+
+
+
+
+
+ Non reentrant function 'fgetpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'fgetpwent_r'.
+
+
+
+ false
+
+
+ Non reentrant function 'getgrent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getgrent_r'.
+
+
+
+ false
+
+
+
+
+
+
+ Non reentrant function 'fgetgrent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'fgetgrent_r'.
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+ Non reentrant function 'getnetgrent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getnetgrent_r'.
+
+
+
+ false
+
+
+
+
+
+
+ Non reentrant function 'getgrnam' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getgrnam_r'.
+
+
+
+ false
+
+
+
+
+
+ Non reentrant function 'getgrgid' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getgrgid_r'.
+
+
+
+ false
+
+
+ Non reentrant function 'getlogin' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getlogin_r'.
+
+
+
+ false
+
+
+ Non reentrant function 'ctermid' called. For threadsafe applications it is recommended to use the reentrant replacement function 'ctermid_r'.
+
strdup
strndup
@@ -1956,6 +2539,7 @@
popen
pclose
+
diff --git a/cfg/std.cfg b/cfg/std.cfg
index 95791a051..2864d6ea3 100644
--- a/cfg/std.cfg
+++ b/cfg/std.cfg
@@ -92,6 +92,7 @@
+
@@ -1435,12 +1436,14 @@
-
+
false
+ Obsolete function 'gets' called. It is recommended to use 'fgets' instead.
+The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun if the input data exceeds the size of the buffer. It is recommended to use the function 'fgets' instead.
diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp
new file mode 100644
index 000000000..207737011
--- /dev/null
+++ b/lib/checkfunctions.cpp
@@ -0,0 +1,71 @@
+/*
+ * Cppcheck - A tool for static C/C++ code analysis
+ * Copyright (C) 2007-2015 Cppcheck team.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+//---------------------------------------------------------------------------
+// Check functions
+//---------------------------------------------------------------------------
+
+#include "checkfunctions.h"
+#include "symboldatabase.h"
+
+//---------------------------------------------------------------------------
+
+
+// Register this check class (by creating a static instance of it)
+namespace {
+ CheckFunctions instance;
+}
+
+void CheckFunctions::check()
+{
+ const bool checkAlloca = (_settings->standards.c >= Standards::C99 && _tokenizer->isC()) || _settings->standards.cpp >= Standards::CPP11;
+
+ const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
+ for (unsigned int i = 0; i < symbolDatabase->functionScopes.size(); i++) {
+ const Scope* scope = symbolDatabase->functionScopes[i];
+ for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
+ if (tok->isName() && tok->varId() == 0 && tok->strAt(1) == "(") {
+ // alloca() is special as it depends on the code being C or C++, so it is not in Library
+ if (checkAlloca && Token::Match(tok, "alloca (") && (!tok->function() || tok->function()->nestedIn->type == Scope::eGlobal)) {
+ if (_tokenizer->isC())
+ reportError(tok, Severity::warning, "allocaCalled",
+ "Obsolete function 'alloca' called. In C99 and later it is recommended to use a variable length array instead.\n"
+ "The obsolete function 'alloca' is called. In C99 and later it is recommended to use a variable length array or "
+ "a dynamically allocated array instead. The function 'alloca' is dangerous for many reasons "
+ "(http://stackoverflow.com/questions/1018853/why-is-alloca-not-considered-good-practice and http://linux.die.net/man/3/alloca).");
+ else
+ reportError(tok, Severity::warning, "allocaCalled",
+ "Obsolete function 'alloca' called. In C++11 and later it is recommended to use std::array<> instead.\n"
+ "The obsolete function 'alloca' is called. In C++11 and later it is recommended to use std::array<> or "
+ "a dynamically allocated array instead. The function 'alloca' is dangerous for many reasons "
+ "(http://stackoverflow.com/questions/1018853/why-is-alloca-not-considered-good-practice and http://linux.die.net/man/3/alloca).");
+ } else {
+ if (tok->function() && tok->function()->hasBody())
+ continue;
+
+ const Library::WarnInfo* wi = _settings->library.getWarnInfo(tok);
+ if (wi) {
+ if (_settings->isEnabled(Severity::toString(wi->severity)) && _settings->standards.c >= wi->standards.c && _settings->standards.cpp >= wi->standards.cpp) {
+ reportError(tok, wi->severity, tok->str() + "Called", wi->message);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/lib/checknonreentrantfunctions.h b/lib/checkfunctions.h
similarity index 57%
rename from lib/checknonreentrantfunctions.h
rename to lib/checkfunctions.h
index ee6173f4c..1a7e706c0 100644
--- a/lib/checknonreentrantfunctions.h
+++ b/lib/checkfunctions.h
@@ -16,55 +16,60 @@
* along with this program. If not, see .
*/
+
//---------------------------------------------------------------------------
-#ifndef checknonreentrantfunctionsH
-#define checknonreentrantfunctionsH
+#ifndef checkfunctionsH
+#define checkfunctionsH
//---------------------------------------------------------------------------
#include "config.h"
#include "check.h"
#include
-#include