summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2012-07-09 18:26:22 +0000
committerrandomdan <randomdan@localhost>2012-07-09 18:26:22 +0000
commit0e0f221692006393417b2ce317edcdc8ee2542c2 (patch)
treec3d6d7cb12ac00b53d3e251dd33cfa7a9cf71361
parentWrite sha1 hashes onto presenter cache files and validate client caches with ... (diff)
downloadproject2-0e0f221692006393417b2ce317edcdc8ee2542c2.tar.bz2
project2-0e0f221692006393417b2ce317edcdc8ee2542c2.tar.xz
project2-0e0f221692006393417b2ce317edcdc8ee2542c2.zip
Fixes suggested by cppcheck
-rw-r--r--project2/Jamfile.jam7
-rw-r--r--project2/cgi/cgiEnvironment.cpp2
-rw-r--r--project2/cgi/cgiStagePresent.cpp4
-rw-r--r--project2/cgi/testCgi.cpp3
-rw-r--r--project2/common/functions/strings.cpp4
-rw-r--r--project2/common/iHaveParameters.cpp2
-rw-r--r--project2/common/logger.cpp3
-rw-r--r--project2/common/memoryCache.cpp3
-rw-r--r--project2/common/options.cpp2
-rw-r--r--project2/common/rowView.cpp4
-rw-r--r--project2/common/singleton.cpp3
-rw-r--r--project2/common/variables-modlookup.cpp2
-rw-r--r--project2/files/fileLog.cpp17
-rw-r--r--project2/files/fsFilterName.cpp12
-rw-r--r--project2/json/parse.cpp1
-rw-r--r--project2/sql/sqlBulkLoad.cpp3
-rw-r--r--project2/sql/sqlCache.cpp3
-rw-r--r--project2/sql/sqlMergeTask.cpp3
-rw-r--r--project2/sql/sqlTask.cpp3
-rw-r--r--project2/sql/sqlTest.cpp3
-rw-r--r--project2/sql/tablepatch.cpp2
-rw-r--r--project2/streams/streamRows.cpp16
22 files changed, 58 insertions, 44 deletions
diff --git a/project2/Jamfile.jam b/project2/Jamfile.jam
index 4a4154f..4eba894 100644
--- a/project2/Jamfile.jam
+++ b/project2/Jamfile.jam
@@ -18,13 +18,6 @@ alias p2parts : : : :
<library>streams//p2streams
;
-project
- : requirements
- <variant>release:<cflags>"-std=c++0x"
- <variant>debug:<cflags>"-W -Wall -Werror -Wwrite-strings -std=c++0x"
- <variant>debug:<linkflags>"-Wl,-z,defs"
- ;
-
build-project console ;
build-project cgi ;
diff --git a/project2/cgi/cgiEnvironment.cpp b/project2/cgi/cgiEnvironment.cpp
index af99f0d..7bb68d2 100644
--- a/project2/cgi/cgiEnvironment.cpp
+++ b/project2/cgi/cgiEnvironment.cpp
@@ -26,6 +26,8 @@ makeVector(const boost::filesystem::path & y)
}
CgiEnvironment::CgiEnvironment() :
+ cgi(NULL),
+ cgienv(NULL),
cgiOptions("Project2 CGI options"),
hpi(new HostnamePlatformIdentifier())
{
diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp
index 1c6edaf..7282def 100644
--- a/project2/cgi/cgiStagePresent.cpp
+++ b/project2/cgi/cgiStagePresent.cpp
@@ -48,10 +48,10 @@ CgiApplicationEngine::PresentStage::run()
header = HttpHeaderPtr(new Project2HttpHeader("404 Not found"));
return NextStage(NULL, this, boost::dynamic_pointer_cast<TransformSource>(presenter), presenter);
}
- catch (ResponseStagePtr p) {
+ catch (ResponseStagePtr & p) {
return NextStage(NULL, p, boost::dynamic_pointer_cast<TransformSource>(p), boost::dynamic_pointer_cast<Presenter>(p));
}
- catch (StagePtr p) {
+ catch (StagePtr & p) {
return NextStage(p, NULL, boost::dynamic_pointer_cast<TransformSource>(p), boost::dynamic_pointer_cast<Presenter>(p));
}
}
diff --git a/project2/cgi/testCgi.cpp b/project2/cgi/testCgi.cpp
index fb480a4..8cf5606 100644
--- a/project2/cgi/testCgi.cpp
+++ b/project2/cgi/testCgi.cpp
@@ -28,7 +28,8 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput {
typedef std::map<std::string, StrPtr> OptStore;
OptStore optStore;
TestInput() :
- opts("Project2 CGI test options")
+ opts("Project2 CGI test options"),
+ runCount(0)
{
opts
TESTOPT("SERVER_NAME", "localhost", "FQDN of web service")
diff --git a/project2/common/functions/strings.cpp b/project2/common/functions/strings.cpp
index 7d3d2b1..6616bba 100644
--- a/project2/common/functions/strings.cpp
+++ b/project2/common/functions/strings.cpp
@@ -14,10 +14,10 @@ class Trim : public VariableImpl {
{
Glib::ustring str = string();
Glib::ustring::const_iterator b = str.begin();
- while (Glib::Unicode::isspace(*b)) b++;
+ while (Glib::Unicode::isspace(*b)) ++b;
Glib::ustring::const_iterator e = str.end();
while (Glib::Unicode::isspace(*--e)) ;
- e++;
+ ++e;
return Glib::ustring(b, e);
}
private:
diff --git a/project2/common/iHaveParameters.cpp b/project2/common/iHaveParameters.cpp
index 5272e5f..f880944 100644
--- a/project2/common/iHaveParameters.cpp
+++ b/project2/common/iHaveParameters.cpp
@@ -39,7 +39,7 @@ IHaveParameters::pop()
VariableType
IHaveParameters::getScopedParameter(const Glib::ustring & name)
{
- for(Stack::const_reverse_iterator ihp = scope.rbegin(); ihp != scope.rend(); ihp++) {
+ for(Stack::const_reverse_iterator ihp = scope.rbegin(); ihp != scope.rend(); ++ihp) {
Parameters::const_iterator i = (*ihp)->parameters.find(name);
if (i != (*ihp)->parameters.end()) {
return i->second;
diff --git a/project2/common/logger.cpp b/project2/common/logger.cpp
index dc02afc..8140155 100644
--- a/project2/common/logger.cpp
+++ b/project2/common/logger.cpp
@@ -8,7 +8,8 @@
Log Logger::log;
Log::Log() :
- lowestLevel(-1)
+ lowestLevel(-1),
+ nextId(0)
{
}
diff --git a/project2/common/memoryCache.cpp b/project2/common/memoryCache.cpp
index cd13930..8c85127 100644
--- a/project2/common/memoryCache.cpp
+++ b/project2/common/memoryCache.cpp
@@ -38,7 +38,8 @@ class MemoryCache : public Cache {
CachedRowSet(const std::vector<VariableType> & k) :
RowSet(NULL),
key(k),
- createdAt(time(NULL))
+ createdAt(time(NULL)),
+ col(0)
{
}
diff --git a/project2/common/options.cpp b/project2/common/options.cpp
index 767fb3b..94ae861 100644
--- a/project2/common/options.cpp
+++ b/project2/common/options.cpp
@@ -83,7 +83,7 @@ Options::operator()(const Glib::ustring & n, TargetPtr t, const Glib::ustring &
Options &
Options::operator()(const Glib::ustring & a)
{
- for (OptionList::const_reverse_iterator i = options.rbegin(); i != options.rend(); i++) {
+ for (OptionList::const_reverse_iterator i = options.rbegin(); i != options.rend(); ++i) {
if (const NamedOption * no = dynamic_cast<const NamedOption *>(i->get())) {
options.push_back(new OptionAlias(a, no));
break;
diff --git a/project2/common/rowView.cpp b/project2/common/rowView.cpp
index 41eceec..c0e5cae 100644
--- a/project2/common/rowView.cpp
+++ b/project2/common/rowView.cpp
@@ -16,7 +16,9 @@ RowView::RowView(ScriptNodePtr p) :
rootName(p, "rootname", Null()),
recordName(p, "recordname"),
required(p, "required", false),
- isObject(p, "isobject", true)
+ isObject(p, "isobject", true),
+ presenter(NULL),
+ rowsFound(false)
{
BOOST_FOREACH(ScriptNodePtr node, p->childrenIn("columns")) {
viewColumns.insert(Columns::value_type(node->get_name(), Variable(node)));
diff --git a/project2/common/singleton.cpp b/project2/common/singleton.cpp
index 91c80ff..76b99d4 100644
--- a/project2/common/singleton.cpp
+++ b/project2/common/singleton.cpp
@@ -9,7 +9,8 @@ class Singleton : public View {
Singleton(ScriptNodePtr p) :
SourceObject(p),
View(p),
- rootName(p, "rootname") {
+ rootName(p, "rootname"),
+ presenter(NULL) {
BOOST_FOREACH(ScriptNodePtr node, p->childrenIn("columns")) {
viewColumns.insert(Columns::value_type(node->get_name(), Variable(node)));
}
diff --git a/project2/common/variables-modlookup.cpp b/project2/common/variables-modlookup.cpp
index 677b628..64ff93d 100644
--- a/project2/common/variables-modlookup.cpp
+++ b/project2/common/variables-modlookup.cpp
@@ -22,7 +22,7 @@ class VariableLookup : public VariableImplDyn, public RowProcessor {
}
static std::string mklist(const Key & k) {
std::string l("(");
- for (Key::const_iterator kp = k.begin(); kp != k.end(); kp++) {
+ for (Key::const_iterator kp = k.begin(); kp != k.end(); ++kp) {
if (kp != k.begin()) l += ", ";
l += kp->operator const std::string &();
}
diff --git a/project2/files/fileLog.cpp b/project2/files/fileLog.cpp
index 9225146..a860080 100644
--- a/project2/files/fileLog.cpp
+++ b/project2/files/fileLog.cpp
@@ -15,24 +15,19 @@ class FileLogDriver : public LogDriverBase {
void message(int priority, const char * msg) const
{
if (priority <= level) {
+ struct tm tm;
+ time_t t = time(NULL);
+ localtime_r(&t, &tm);
+ char tmbuf[30];
+ strftime(tmbuf, sizeof(tmbuf), "%F %T", &tm);
fprintf(file, "%s %-6.*s%s\n",
- timeStr(), 5, Log::priorityName(level), msg);
+ tmbuf, 5, Log::priorityName(level), msg);
fflush(file);
}
}
private:
FILE * file;
-
- const char * timeStr() const
- {
- struct tm tm;
- time_t t = time(NULL);
- localtime_r(&t, &tm);
- strftime(tmbuf, sizeof(tmbuf), "%F %T", &tm);
- return tmbuf;
- }
- mutable char tmbuf[30];
};
DECLARE_GENERIC_LOADER("file", LogDriverLoader, FileLogDriver);
diff --git a/project2/files/fsFilterName.cpp b/project2/files/fsFilterName.cpp
index ad65c7e..cc1104f 100644
--- a/project2/files/fsFilterName.cpp
+++ b/project2/files/fsFilterName.cpp
@@ -24,8 +24,8 @@ class FsRowSpecName : public FsRows::SpecBase {
if ((*wild != *string) && (*wild != '?')) {
return false;
}
- wild++;
- string++;
+ ++wild;
+ ++string;
}
Glib::ustring::const_iterator cp, mp;
@@ -36,10 +36,10 @@ class FsRowSpecName : public FsRows::SpecBase {
}
mp = wild;
cp = string;
- cp++;
+ ++cp;
} else if ((*wild == *string) || (*wild == '?')) {
- wild++;
- string++;
+ ++wild;
+ ++string;
} else {
wild = mp;
string = cp++;
@@ -47,7 +47,7 @@ class FsRowSpecName : public FsRows::SpecBase {
}
while (*wild == '*') {
- wild++;
+ ++wild;
}
return wild == patt.end();
}
diff --git a/project2/json/parse.cpp b/project2/json/parse.cpp
index 3f485c4..cb41dd2 100644
--- a/project2/json/parse.cpp
+++ b/project2/json/parse.cpp
@@ -54,6 +54,7 @@ namespace json {
}
s++;
}
+ str += gunichar(c);
s--;
}
break;
diff --git a/project2/sql/sqlBulkLoad.cpp b/project2/sql/sqlBulkLoad.cpp
index 227f06c..4d9604a 100644
--- a/project2/sql/sqlBulkLoad.cpp
+++ b/project2/sql/sqlBulkLoad.cpp
@@ -10,7 +10,8 @@ class SqlBulkLoad : public Task {
Task(p),
dataSource(p, "datasource"),
targetTable(p, "targettable"),
- extras(p, "extras")
+ extras(p, "extras"),
+ db(NULL)
{
p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&stream));
}
diff --git a/project2/sql/sqlCache.cpp b/project2/sql/sqlCache.cpp
index 08d2831..7fe0408 100644
--- a/project2/sql/sqlCache.cpp
+++ b/project2/sql/sqlCache.cpp
@@ -22,7 +22,8 @@ typedef boost::shared_ptr<DB::ModifyCommand> ModifyPtr;
class SqlCache : public Cache {
public:
SqlCache(ScriptNodePtr p) :
- Cache(p)
+ Cache(p),
+ db(NULL)
{
}
diff --git a/project2/sql/sqlMergeTask.cpp b/project2/sql/sqlMergeTask.cpp
index 9611fa9..0b19c5e 100644
--- a/project2/sql/sqlMergeTask.cpp
+++ b/project2/sql/sqlMergeTask.cpp
@@ -24,7 +24,8 @@ class SqlMergeInsert : IHaveParameters, public Task {
SqlMergeInsert(ScriptNodePtr p) :
SourceObject(p),
IHaveParameters(p),
- Task(p) {
+ Task(p),
+ insert(NULL) {
}
void execute() const {
unsigned int col = 0;
diff --git a/project2/sql/sqlTask.cpp b/project2/sql/sqlTask.cpp
index 852069d..03f67de 100644
--- a/project2/sql/sqlTask.cpp
+++ b/project2/sql/sqlTask.cpp
@@ -15,7 +15,8 @@ SqlTask::SqlTask(ScriptNodePtr p) :
Task(p),
dataSource(p, "datasource"),
filter(p, "filter", ""),
- sqlCommand(p->child("sql"))
+ sqlCommand(p->child("sql")),
+ db(NULL)
{
p->script->loader.addLoadTargetSub(p, "changes", false, Storer::into<ElementLoader>(&changesNOEs));
p->script->loader.addLoadTargetSub(p, "nochanges", false, Storer::into<ElementLoader>(&noChangesNOEs));
diff --git a/project2/sql/sqlTest.cpp b/project2/sql/sqlTest.cpp
index 3cf25b7..f45b2c9 100644
--- a/project2/sql/sqlTest.cpp
+++ b/project2/sql/sqlTest.cpp
@@ -20,7 +20,8 @@ SqlTest::SqlTest(ScriptNodePtr p) :
filter(p, "filter", ""),
testOp(p, "testOp", "=="),
testValue(p, "testValue"),
- sqlCommand(p->child("sql"))
+ sqlCommand(p->child("sql")),
+ db(NULL)
{
}
diff --git a/project2/sql/tablepatch.cpp b/project2/sql/tablepatch.cpp
index 733f94f..8d61b66 100644
--- a/project2/sql/tablepatch.cpp
+++ b/project2/sql/tablepatch.cpp
@@ -39,7 +39,7 @@ TablePatch::addKey(const TablePatch::Column & c)
void
TablePatch::patch(const WhereProvider * where, const char * order)
{
- if (pk.size() == 0) {
+ if (pk.empty()) {
throw PatchCheckFailure();
}
if (doDelete) {
diff --git a/project2/streams/streamRows.cpp b/project2/streams/streamRows.cpp
index e0cefca..f807e4f 100644
--- a/project2/streams/streamRows.cpp
+++ b/project2/streams/streamRows.cpp
@@ -6,6 +6,7 @@
#include "rowProcessor.h"
#include <boost/algorithm/string/predicate.hpp>
+SimpleSysCallException(ReallocFail);
class RowProcessor;
/// Base class for Project2 components that create a row set based on the contents of a byte stream
@@ -17,6 +18,7 @@ class StreamRows : public DefinedColumns, public RowSet {
ColumnValues(rows),
sr(rows),
rp(proc),
+ skipheader(rows->skipheader),
inQuotes(false),
prevWasQuote(false),
curCol(fields.begin())
@@ -67,7 +69,12 @@ class StreamRows : public DefinedColumns, public RowSet {
const char * src;
size_t srcLen;
if (bufLen) {
- src = buf = (char*)realloc(buf, bufLen + bytesLen);
+ char * nbuf = (char*)realloc(buf, bufLen + bytesLen);
+ if (!nbuf) {
+ free(buf);
+ throw ReallocFail(errno);
+ }
+ src = buf = nbuf;
memcpy(buf + bufLen, bytes, bytesLen);
srcLen = bufLen += bytesLen;
}
@@ -93,7 +100,12 @@ class StreamRows : public DefinedColumns, public RowSet {
size_t newBuf = srcLen - used;
if (newBuf) {
if (bufLen < newBuf) {
- buf = (char*)realloc(buf, newBuf);
+ char * nbuf = (char*)realloc(buf, newBuf);
+ if (!nbuf) {
+ free(buf);
+ throw ReallocFail(errno);
+ }
+ buf = nbuf;
}
bufLen = newBuf;
memcpy(buf, src + used, bufLen);