FIX (good practices)

This commit is contained in:
Andrea Bontempi 2015-03-05 16:35:24 +01:00
parent 0136d780f1
commit c27365f969
5 changed files with 11 additions and 12 deletions

View file

@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 2.6)
project(ProjectRiddle)
# Project settings
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
# Uncomment to enable compiler warning
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Weffc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Weffc++")
set(SYSCONF_INSTALL_DIR
"/etc"

View file

@ -58,7 +58,7 @@ inline std::string decodeHexText ( std::string raw ) {
std::string text;
for ( int i = 0; i <= raw.size(); i += 2 ) {
for ( unsigned int i = 0; i <= raw.size(); i += 2 ) {
std::string comp;
comp += ( char ) raw[i];
comp += ( char ) raw[i+1];
@ -72,12 +72,12 @@ inline std::string decodeHexText ( std::string raw ) {
}
/** enccoding to hex format */
/** encoding to hex format */
inline std::string encodeHexText ( const unsigned char *text, uint32_t size ) {
std::stringstream out;
for ( int i = 0; i < size; i++ ) {
for ( unsigned int i = 0; i < size; i++ ) {
out << std::setfill ( '0' ) << std::setw ( 2 ) << std::hex << ( int ) text[i];

View file

@ -181,10 +181,10 @@ namespace network {
protected:
uint64_t timeEpoch; /** Timestamp */
uint32_t timeMillis; /** Millisecond from timestamp */
uint32_t pkgLength; /** Packet length */
std::string rawData; /** Raw packet recived from riddle */
uint64_t timeEpoch = 0; /** Timestamp */
uint32_t timeMillis = 0; /** Millisecond from timestamp */
uint32_t pkgLength = 0; /** Packet length */
std::string rawData = ""; /** Raw packet recived from riddle */
/**
* Extracts in hexadecimal format a portion of the captured packet.

View file

@ -43,8 +43,8 @@ namespace network {
class TcpStream
{
private:
uint64_t timeEpoch;
uint32_t timeMillis;
uint64_t timeEpoch = 0;
uint32_t timeMillis = 0;
network::mac_address macAddress[2];
boost::asio::ip::address ipAddress[2];

View file

@ -44,7 +44,6 @@
void writeout ( network::TcpStream* stream, bool tofile ) {
if ( tofile ) {
std::stringstream filename;
char buffer[10];
filename << "flow_";
filename << stream->getTimeEpoch();
filename << "_";