new code must now adhere to the same coding standard

master
Emanuel Vintila 2018-01-07 10:11:46 +01:00
parent 932535d470
commit 482fcb2cd4
7 changed files with 20 additions and 30 deletions

View File

@ -25,12 +25,12 @@ std::string CfgBase::_get(const std::string& name, XMLElement* elem)
std::string CfgBase::get(const std::string& name, XMLElement* elem)
{
if (!elem)
{
if (!_elem)
if (!elem) {
if (!_elem) {
THROWEXCEPTION("Error: accessing null XML element");
else
} else {
elem = _elem;
}
}
std::string result;

View File

@ -73,12 +73,10 @@ struct Mapper * new_mapper(struct Matcher * matcher){
mapper->complete_numOfTokens = complete_numOfTokens;
mapper->classwise_numOfTokens = malloc(sizeof(int)*matcher->numOfClasses);
if (complete_numOfTokens != 0)
{
if (complete_numOfTokens != 0) {
mapper->supports = malloc(sizeof(double)*complete_numOfTokens);
}
else
{
else {
// allocate bytes for one double -- to be safely freed
mapper->supports = malloc(sizeof(double));
}

View File

@ -27,12 +27,9 @@ struct BayesSignature * new_Signature_i(int maxNumOfTokens, char * filename){
struct BayesSignature * signature;
signature = (struct BayesSignature *)malloc(sizeof(struct BayesSignature));
// Allocate memory for the pointers to the actual Tokens
if (maxNumOfTokens != 0)
{
if (maxNumOfTokens != 0) {
signature->tokens = (struct Token **)malloc(maxNumOfTokens*sizeof(struct Token *));
}
else
{
} else {
// allocate bytes for one Token pointer -- to be safely freed
signature->tokens = (struct Token **)malloc(sizeof(struct Token *));
}
@ -87,12 +84,9 @@ struct BayesSignature * new_Signature_s(const char * absolute_path, char * filen
/** Allocate Memory for the **file and for the tokens and supports */
int i = 0;
char ** lines;
if (numOfLines != 0)
{
if (numOfLines != 0) {
lines = (char **)malloc(numOfLines * sizeof(char *));
}
else
{
} else {
// allocate bytes for one char pointer -- to be safely freed
lines = (char **)malloc(sizeof(char *));
}

View File

@ -45,12 +45,10 @@ double get_double(char string[]){
if (num_tokens < 1){
// no tokens -> cannot compose a number
}
else if (num_tokens == 1){
}else if (num_tokens == 1){
// only one token
ret = atoi(tokens[0]);
}
else{
}else{
//printf("STRINGS: %s , %s\n", tokens[0], tokens[1]);
//sscanf(string, "%d %d", &pre_comma, &post_comma);
@ -138,12 +136,9 @@ char ** get_filenames(const char * directory, int * num_of_files) {
/* Get each directory entry from pDIR and store its name
* in an array */
char ** filenames;
if ( filecounter != 0)
{
if ( filecounter != 0) {
filenames = (char **)malloc(sizeof(char*)*filecounter);
}
else
{
} else {
// allocate bytes for 1 pointer -- to be safely freed
// filenames will remain empty and will not be used
filenames = (char **)malloc(sizeof(char*));

View File

@ -34,9 +34,9 @@ namespace InformationElement {
{
if (length==0) {
const ipfix_identifier* ipfixid = ipfix_id_lookup(id, enterprise);
if (ipfixid)
if (ipfixid) {
this->length = ipfixid->length;
else {
} else {
msg(MSG_INFO, "WARNING: received unknown IE type id: %s", toString().c_str());
}
}

View File

@ -98,10 +98,11 @@ Rule* AggregatorBaseCfg::readRule(XMLElement* elem) {
// exclude coexistence of patterns and biflow aggregation
if(rule->biflowAggregation) {
for(int i=0; i < rule->fieldCount; i++) {
if(rule->field[i]->pattern)
if(rule->field[i]->pattern) {
msg(MSG_ERROR, "AggregatorBaseCfg: Match pattern for id=%d ignored because biflow aggregation is enabled.", rule->field[i]->type.id);
free(rule->field[i]->pattern);
rule->field[i]->pattern = NULL;
}
}
}
}

View File

@ -41,6 +41,8 @@ RandomSampler::RandomSampler(int n, int N) : samplingSize(N), acceptSize(n), cur
if(n > N) {
msg(MSG_ERROR, "%d out-of %d makes no sense - exchanging values", n, N);
samplingSize = n;
acceptSize = N;
N=n;
}