fix some warnings
This commit is contained in:
parent
ade5b4378f
commit
8bd977ba62
|
@ -8,9 +8,9 @@ long **getlongArray(int N, int M) /* Allocate the array */
|
||||||
/* Check if allocation succeeded. (check for NULL pointer) */
|
/* Check if allocation succeeded. (check for NULL pointer) */
|
||||||
int i;
|
int i;
|
||||||
long **array;
|
long **array;
|
||||||
array = (long **) malloc(N*sizeof(long *));
|
array = (long **)malloc(N * sizeof(long *));
|
||||||
for(i = 0 ; i < N ; i++)
|
for (i = 0; i < N; i++)
|
||||||
array[i] = (long *) malloc( M*sizeof(long) );
|
array[i] = (long *)malloc(M * sizeof(long));
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,42 +19,48 @@ double **getDoubleArray(int N, int M) /* Allocate the array */
|
||||||
/* Check if allocation succeeded. (check for NULL pointer) */
|
/* Check if allocation succeeded. (check for NULL pointer) */
|
||||||
int i;
|
int i;
|
||||||
double **array;
|
double **array;
|
||||||
array = (double **) malloc(N*sizeof(double *));
|
array = (double **)malloc(N * sizeof(double *));
|
||||||
for(i = 0 ; i < N ; i++)
|
for (i = 0; i < N; i++)
|
||||||
array[i] = (double *) malloc( M*sizeof(double));
|
array[i] = (double *)malloc(M * sizeof(double));
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillArrayWithRawData(char *rawDataFileName,long** p, int N, int M) {
|
void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
|
||||||
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
size_t bufsize = 200;
|
size_t bufsize = 200;
|
||||||
buffer = (char *)malloc(bufsize * sizeof(char));
|
buffer = (char *)malloc(bufsize * sizeof(char));
|
||||||
char* token;
|
int token;
|
||||||
|
|
||||||
FILE *f = fopen(rawDataFileName,"r");
|
FILE *f = fopen(rawDataFileName, "r");
|
||||||
|
|
||||||
for(i = 0 ; i < N ; i++){
|
for (i = 0; i < N; i++)
|
||||||
if (!getline(&buffer, &bufsize, f)) break; // condition d'arret de la boucle si fichier fini
|
{
|
||||||
|
if (!getline(&buffer, &bufsize, f))
|
||||||
|
break; // condition d'arret de la boucle si fichier fini
|
||||||
j = 0;
|
j = 0;
|
||||||
while((token = strsep(&buffer,",")) != NULL){ // séparation valeur par virgule initiale : csv
|
while ((token = strsep(&buffer, ",")) != 0)
|
||||||
p[i][j] = atoi(token);
|
{ // séparation valeur par virgule initiale : csv
|
||||||
|
p[i][j] = token;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief print all the element of a bidimensionnal array p of shape : N x M
|
* @brief print all the element of a bidimensionnal array p of shape : N x M
|
||||||
*/
|
*/
|
||||||
void printArrayData(long** p, int N, int M) {
|
void printArrayData(long **p, int N, int M)
|
||||||
int i, j;
|
{
|
||||||
for(i = 0 ; i < N ; i++){
|
for (int i = 0; i < N; i++)
|
||||||
printf("line n°%d : " , i);
|
{
|
||||||
for(int j = 0 ; j < M ; j++){
|
printf("line n°%d : ", i);
|
||||||
printf("%ld , " , p[i][j]);
|
for (int j = 0; j < M; j++)
|
||||||
if(j==(M-1)) printf("\n");
|
{
|
||||||
|
printf("%ld , ", p[i][j]);
|
||||||
|
if (j == (M - 1))
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,9 +73,14 @@ void printArrayData(long** p, int N, int M) {
|
||||||
* @return true if the array contaign no NULL element
|
* @return true if the array contaign no NULL element
|
||||||
* @return false if at least one element is null
|
* @return false if at least one element is null
|
||||||
*/
|
*/
|
||||||
bool checkArrayFullyFill(long **p, int N){
|
bool checkArrayFullyFill(long **p, int N)
|
||||||
for(int i = 0 ; i < N ; i++){
|
{
|
||||||
if(p[i][0] == '\0'){ return false; }
|
for (int i = 0; i < N; i++)
|
||||||
|
{
|
||||||
|
if (p[i][0] == '\0')
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -80,8 +91,10 @@ bool checkArrayFullyFill(long **p, int N){
|
||||||
* @param p array to free memory
|
* @param p array to free memory
|
||||||
* @param N number of rows in array
|
* @param N number of rows in array
|
||||||
*/
|
*/
|
||||||
void freeArray(long **p, int N) {
|
void freeArray(long **p, int N)
|
||||||
for(int i = 0 ; i < N ; i++){
|
{
|
||||||
|
for (int i = 0; i < N; i++)
|
||||||
|
{
|
||||||
free(p[i]);
|
free(p[i]);
|
||||||
}
|
}
|
||||||
free(p);
|
free(p);
|
||||||
|
@ -95,12 +108,13 @@ void freeArray(long **p, int N) {
|
||||||
* @param M numbers of columns to have i the array
|
* @param M numbers of columns to have i the array
|
||||||
* @return long** the array fill with raw data
|
* @return long** the array fill with raw data
|
||||||
*/
|
*/
|
||||||
long **getRawDataArray(char* rawDataFileName){
|
long **getRawDataArray(char *rawDataFileName)
|
||||||
|
{
|
||||||
long **p;
|
long **p;
|
||||||
p = getlongArray(nRowRawData, nCol);
|
p = getlongArray(nRowRawData, nCol);
|
||||||
fillArrayWithRawData(rawDataFileName,p ,nRowRawData, nCol);
|
fillArrayWithRawData(rawDataFileName, p, nRowRawData, nCol);
|
||||||
//if(checkArrayFullyFill(p,nRow)){
|
// if(checkArrayFullyFill(p,nRow)){
|
||||||
//clearRawData(N);
|
// clearRawData(N);
|
||||||
return p;
|
return p;
|
||||||
/*}
|
/*}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
long **getRawDataArray(char *rawDataFileName);
|
long **getRawDataArray(char *rawDataFileName);
|
||||||
void printArrayData(long** p, int N, int M);
|
void printArrayData(long **p, int N, int M);
|
||||||
void freeArray(long **p, int N);
|
void freeArray(long **p, int N);
|
||||||
bool checkArrayFullyFill(long **p, int N );
|
bool checkArrayFullyFill(long **p, int N);
|
||||||
double **getDoubleArray(int N, int M);
|
double **getDoubleArray(int N, int M);
|
|
@ -42,6 +42,7 @@ void *threadCalculPower(void *vargp)
|
||||||
remove(fileName);
|
remove(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *threadCalculAverage(void *vargp)
|
void *threadCalculAverage(void *vargp)
|
||||||
|
@ -58,6 +59,7 @@ void *threadCalculAverage(void *vargp)
|
||||||
remove(fileName);
|
remove(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *threadCalculBoth(void *vargp)
|
void *threadCalculBoth(void *vargp)
|
||||||
|
@ -75,6 +77,7 @@ void *threadCalculBoth(void *vargp)
|
||||||
remove(fileName);
|
remove(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *threadCalculGrowthRate(void *vargp)
|
void *threadCalculGrowthRate(void *vargp)
|
||||||
|
@ -124,6 +127,7 @@ void *threadCalculGrowthRate(void *vargp)
|
||||||
remove(fileName);
|
remove(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -144,9 +148,14 @@ int main(int argc, char **argv)
|
||||||
firstRawDataQueue = queueCreateEmpty(); // change this for create empty
|
firstRawDataQueue = queueCreateEmpty(); // change this for create empty
|
||||||
|
|
||||||
pthread_t rawData;
|
pthread_t rawData;
|
||||||
pthread_create(&rawData, NULL, threadSimulateFlux, (void *)&rawData);
|
if (pthread_create(&rawData, NULL, threadSimulateFlux, "threadSimulflux") != 0)
|
||||||
|
{
|
||||||
|
perror("pthread_create() error");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
pthread_t calcul;
|
pthread_t calcul;
|
||||||
pthread_create(&calcul, NULL, threadCalculGrowthRate, (void *)&calcul);
|
pthread_create(&calcul, NULL, threadCalculGrowthRate, "threadCalcul");
|
||||||
|
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
|
@ -123,7 +123,6 @@ bool writeOneRawData(FILE *rawDataFile)
|
||||||
char buff2[18];
|
char buff2[18];
|
||||||
int32_t values[8];
|
int32_t values[8];
|
||||||
uint32_t valbin[8];
|
uint32_t valbin[8];
|
||||||
quartet value;
|
|
||||||
|
|
||||||
if (fread(&buff, 26, 1, stdin))
|
if (fread(&buff, 26, 1, stdin))
|
||||||
{
|
{
|
||||||
|
@ -146,11 +145,13 @@ bool writeOneRawData(FILE *rawDataFile)
|
||||||
strncpy(&buff[8], buff2, 18);
|
strncpy(&buff[8], buff2, 18);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastIndex = lastIndexCaptor();
|
int lastIndex = lastIndexCaptor();
|
||||||
for (int i = 1; i < 9; i++)
|
for (int i = 1; i < 9; i++)
|
||||||
{
|
{
|
||||||
if (selectionCaptors[i - 1])
|
if (selectionCaptors[i - 1])
|
||||||
{
|
{
|
||||||
|
quartet value;
|
||||||
value.octet1 = buff[3 * i + 1];
|
value.octet1 = buff[3 * i + 1];
|
||||||
value.octet2 = buff[3 * i + 2];
|
value.octet2 = buff[3 * i + 2];
|
||||||
value.octet3 = buff[3 * i + 3];
|
value.octet3 = buff[3 * i + 3];
|
||||||
|
@ -183,6 +184,7 @@ bool writeOneRawData(FILE *rawDataFile)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *threadSimulateFlux(void *vargp)
|
void *threadSimulateFlux(void *vargp)
|
||||||
|
@ -202,8 +204,9 @@ void *threadSimulateFlux(void *vargp)
|
||||||
queueAddLastQ(firstRawDataQueue, fileName, strlen(fileName));
|
queueAddLastQ(firstRawDataQueue, fileName, strlen(fileName));
|
||||||
// prepare next file now
|
// prepare next file now
|
||||||
fileName = createNewRawDataFileName();
|
fileName = createNewRawDataFileName();
|
||||||
FILE *rawDataFile = fopen(fileName, "w+");
|
rawDataFile = fopen(fileName, "w+");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rawDataWriteFlag = false;
|
rawDataWriteFlag = false;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue