Skip to content

Commit

Permalink
Include checker now ensures no deprecated use of C library headers #118
Browse files Browse the repository at this point in the history
And I have removed all such uses (and slightly tidied up main.cc's
include statements).
  • Loading branch information
Rupert Nash authored and Rupert Nash committed Jan 26, 2012
1 parent b091d46 commit 5194f90
Show file tree
Hide file tree
Showing 36 changed files with 128 additions and 129 deletions.
1 change: 0 additions & 1 deletion Code/D3Q15.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "D3Q15.h"
#include <cmath>

namespace hemelb
{
Expand Down
2 changes: 1 addition & 1 deletion Code/SimulationMaster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <map>
#include <limits>
#include <stdlib.h>
#include <cstdlib>

/**
* Constructor for the SimulationMaster class
Expand Down
1 change: 0 additions & 1 deletion Code/configuration/SimConfig.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef HEMELB_CONFIGURATION_SIMCONFIG_H
#define HEMELB_CONFIGURATION_SIMCONFIG_H

#include <string.h>
#include <vector>
#include "tinyxml.h"
#include "util/Vector3D.h"
Expand Down
1 change: 0 additions & 1 deletion Code/debug/Debugger.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef HEMELB_DEBUG_DEBUGGER_H
#define HEMELB_DEBUG_DEBUGGER_H

#include <stdarg.h>
#include <string>

namespace hemelb
Expand Down
6 changes: 3 additions & 3 deletions Code/debug/common/ActiveDebugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <cerrno>
#include <cstdio>

#include <stdarg.h>
#include <cstdarg>

#include <unistd.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -43,9 +43,9 @@ namespace hemelb

void ActiveDebugger::Print(const char* iFormat, ...)
{
va_list args;
std::va_list args;
va_start(args, iFormat);
vprintf(iFormat, args);
std::vprintf(iFormat, args);
va_end(args);
}

Expand Down
2 changes: 1 addition & 1 deletion Code/geometry/GeometryReader.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <math.h>
#include <cmath>
#include <list>
#include <map>

Expand Down
6 changes: 3 additions & 3 deletions Code/io/writers/xdr/XdrFileWriter.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <stdio.h>
#include <cstdio>
#include "io/writers/xdr/xdr.h"
#include "io/writers/xdr/XdrFileWriter.h"

Expand All @@ -15,7 +15,7 @@ namespace hemelb
// object to write to it.
XdrFileWriter::XdrFileWriter(const std::string& fileName, const std::string& mode)
{
myFile = fopen(fileName.c_str(), mode.c_str());
myFile = std::fopen(fileName.c_str(), mode.c_str());
xdrstdio_create(&mXdr, myFile, XDR_ENCODE);
}

Expand All @@ -25,7 +25,7 @@ namespace hemelb
XdrFileWriter::~XdrFileWriter()
{
xdr_destroy(&mXdr);
fclose(myFile);
std::fclose(myFile);
}

} // namespace xdr
Expand Down
4 changes: 2 additions & 2 deletions Code/io/writers/xdr/XdrFileWriter.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef HEMELB_IO_WRITERS_XDR_XDRFILEWRITER_H
#define HEMELB_IO_WRITERS_XDR_XDRFILEWRITER_H

#include <stdio.h>
#include <cstdio>
#include <string>

#include "io/writers/xdr/XdrWriter.h"
Expand All @@ -26,7 +26,7 @@ namespace hemelb
~XdrFileWriter();

private:
FILE *myFile;
std::FILE *myFile;

};

Expand Down
1 change: 0 additions & 1 deletion Code/io/writers/xdr/XdrReader.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <stdio.h>
#include "io/writers/xdr/xdr.h"
#include "io/writers/xdr/XdrReader.h"

Expand Down
2 changes: 1 addition & 1 deletion Code/lb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ add_library(hemelb_lb
IncompressibilityChecker.cc
kernels/rheologyModels/AbstractRheologyModel.cc kernels/rheologyModels/CarreauYasudaRheologyModel.cc
kernels/rheologyModels/CassonRheologyModel.cc kernels/rheologyModels/TruncatedPowerLawRheologyModel.cc
lattices/LatticeInfo.cc lattices/D3Q19.cc lattices/D3Q27.cc lb.cc SimulationState.cc StabilityTester.cc
lattices/LatticeInfo.cc lattices/D3Q19.cc lattices/D3Q27.cc SimulationState.cc StabilityTester.cc
)
6 changes: 3 additions & 3 deletions Code/lb/HFunction.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef HEMELB_LB_HFUNCTION_H
#define HEMELB_LB_HFUNCTION_H

#include <math.h>
#include <cmath>
#include <cstdlib>

#include "constants.h"
Expand Down Expand Up @@ -37,7 +37,7 @@ namespace hemelb
{
dH += (f_alpha[ii] < 0.0 ?
-1.0 :
1.0) * (mFEq[ii] - mF[ii]) * (1.0 + std::log(fabs(f_alpha[ii]) / LatticeType::EQMWEIGHTS[ii]));
1.0) * (mFEq[ii] - mF[ii]) * (1.0 + std::log(std::fabs(f_alpha[ii]) / LatticeType::EQMWEIGHTS[ii]));
}
}

Expand Down Expand Up @@ -75,7 +75,7 @@ namespace hemelb

for (unsigned int ii = 0; ii < LatticeType::NUMVECTORS; ++ii)
{
H += h(fabs(fAlpha[ii]), 1.0 / LatticeType::EQMWEIGHTS[ii]) - h(mF[ii], 1.0 / LatticeType::EQMWEIGHTS[ii]);
H += h(std::fabs(fAlpha[ii]), 1.0 / LatticeType::EQMWEIGHTS[ii]) - h(mF[ii], 1.0 / LatticeType::EQMWEIGHTS[ii]);
}
}

Expand Down
1 change: 0 additions & 1 deletion Code/lb/boundaries/BoundaryComms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "lb/boundaries/BoundaryValues.h"
#include "topology/NetworkTopology.h"
#include "util/utilityFunctions.h"
#include <math.h>

namespace hemelb
{
Expand Down
1 change: 0 additions & 1 deletion Code/lb/boundaries/BoundaryValues.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "util/fileutils.h"
#include <algorithm>
#include <fstream>
#include <math.h>

namespace hemelb
{
Expand Down
15 changes: 0 additions & 15 deletions Code/lb/lb.cc

This file was deleted.

4 changes: 2 additions & 2 deletions Code/lb/streamers/BaseStreamer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef HEMELB_LB_STREAMERS_BASESTREAMER_H
#define HEMELB_LB_STREAMERS_BASESTREAMER_H

#include <math.h>
#include <cmath>

#include "geometry/LatticeData.h"
#include "vis/Control.h"
Expand Down Expand Up @@ -111,7 +111,7 @@ namespace hemelb
}

// TODO: It'd be nice if the /iDensity were unnecessary.
distribn_t lVelocity = sqrt(iVx * iVx + iVy * iVy + iVz * iVz) / iDensity;
distribn_t lVelocity = std::sqrt(iVx * iVx + iVy * iVy + iVz * iVz) / iDensity;
iControl->RegisterSite(site.GetIndex(), iDensity, lVelocity, rtStress);
}
}
Expand Down
16 changes: 8 additions & 8 deletions Code/log/LoggerCommon.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdarg>

#include "mpiInclude.h"
#include "util/utilityFunctions.h"
Expand All @@ -15,7 +15,7 @@ namespace hemelb
double Logger::startTime = -1.0;

template<>
void Logger::LogInternal<OnePerCore>(std::string format, va_list args)
void Logger::LogInternal<OnePerCore>(std::string format, std::va_list args)
{
if (thisRank < 0)
{
Expand All @@ -24,16 +24,16 @@ namespace hemelb
}

char lead[40];
sprintf(lead, "[Rank %.6i, %.1fs]: ", thisRank, util::myClock() - startTime);
std::sprintf(lead, "[Rank %.6i, %.1fs]: ", thisRank, util::myClock() - startTime);

std::string overFormat(lead);
overFormat.append(format).append("\n");

vprintf(overFormat.c_str(), args);
std::vprintf(overFormat.c_str(), args);
}

template<>
void Logger::LogInternal<Singleton>(std::string format, va_list args)
void Logger::LogInternal<Singleton>(std::string format, std::va_list args)
{
if (thisRank < 0)
{
Expand All @@ -44,10 +44,10 @@ namespace hemelb
if (thisRank == 0)
{
char lead[20];
sprintf(lead, "![%.1fs]", util::myClock() - startTime);
std::sprintf(lead, "![%.1fs]", util::myClock() - startTime);

std::string newFormat = std::string(lead);
vprintf(newFormat.append(format).append("\n").c_str(), args);
std::vprintf(newFormat.append(format).append("\n").c_str(), args);
}
}
}
Expand Down
16 changes: 1 addition & 15 deletions Code/main.cc
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#include "constants.h"
#include "util/fileutils.h"
#include "util/utilityFunctions.h"
#include "lb/lb.h"
#include "log/Logger.h"

#include "configuration/CommandLine.h"
#include "SimulationMaster.h"

#include "debug/Debugger.h"



int main(int argc, char *argv[])
{
// main function needed to perform the entire simulation. Some
Expand All @@ -27,4 +14,3 @@ int main(int argc, char *argv[])

return (0);
}

1 change: 0 additions & 1 deletion Code/reporting/Reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <string>
#include <vector>
#include <stdarg.h>
#include "configuration/SimConfig.h"
#include "configuration/CommandLine.h"
#include "log/Logger.h"
Expand Down
2 changes: 1 addition & 1 deletion Code/steering/Network.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef HEMELB_STEERING_NETWORK_H
#define HEMELB_STEERING_NETWORK_H

#include <string.h>
#include <string>

#include "steering/ClientConnection.h"
#include "net/IteratedAction.h"
Expand Down
8 changes: 4 additions & 4 deletions Code/steering/basic/ClientConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <signal.h>
#include <csignal>
#include <fcntl.h>
#include <netinet/in.h>

Expand All @@ -25,9 +25,9 @@ namespace hemelb
{
char thisMachineName[255];
gethostname(thisMachineName, 255);
FILE *f = fopen("env_details.asc", "w");
fprintf(f, "%s\n", thisMachineName);
fclose(f);
std::FILE *f = std::fopen("env_details.asc", "w");
std::fprintf(f, "%s\n", thisMachineName);
std::fclose(f);
}

// Send the steering session id we're using to the rendezvous resource.
Expand Down
Loading

0 comments on commit 5194f90

Please sign in to comment.