Commit efdc5601 authored by Julien Nabet's avatar Julien Nabet
Browse files

cppcheck: fix 1 kind of reports

(warning) Storing fgetc() return value in char variable and then comparing with EOF
+ optimize a bit by moving the instruction "buf[i]= '\0';" inside the loop, outside from it.
(only non example files have been changed)
parent 4036b0cd
......@@ -173,7 +173,7 @@ _DC_get_file(char *fn)
if ((f= fopen(fn, "r")) != NULL)
{
int bs= 100, i;
char c;
int c;
buf= malloc(bs);
i= 0;
......@@ -185,10 +185,10 @@ _DC_get_file(char *fn)
bs+= 100;
buf= realloc(buf, bs);
}
buf[i]= c;
buf[i]= (char)c;
i++;
buf[i]= '\0';
}
buf[i]= '\0';
fclose(f);
}
return(buf);
......@@ -363,7 +363,7 @@ _DC_read_message(char *box, char *name, int del_msg)
if ((f= fopen(fn, "r")) != NULL)
{
int bs= 100, i;
char c;
int c;
buf= malloc(bs);
i= 0;
......@@ -375,10 +375,10 @@ _DC_read_message(char *box, char *name, int del_msg)
bs+= 100;
buf= realloc(buf, bs);
}
buf[i]= c;
buf[i]= (char)c;
i++;
buf[i]= '\0';
}
buf[i]= '\0';
fclose(f);
if (del_msg)
unlink(fn);
......
......@@ -32,7 +32,7 @@ get_file(char *fn)
if ((f= fopen(fn, "r")) != NULL)
{
int bs= 100, i;
char c;
int c;
buf= malloc(bs);
i= 0;
......@@ -44,10 +44,10 @@ get_file(char *fn)
bs+= 100;
buf= realloc(buf, bs);
}
buf[i]= c;
buf[i]= (char)c;
i++;
buf[i]= '\0';
}
buf[i]= '\0';
fclose(f);
}
return(buf);
......
......@@ -177,7 +177,7 @@ _DC_get_file(char *fn)
if ((f= fopen(fn, "r")) != NULL)
{
int bs= 100, i;
char c;
int c;
buf= malloc(bs);
i= 0;
......@@ -189,10 +189,10 @@ _DC_get_file(char *fn)
bs+= 100;
buf= realloc(buf, bs);
}
buf[i]= c;
buf[i]= (char)c;
i++;
buf[i]= '\0';
}
buf[i]= '\0';
fclose(f);
}
return(buf);
......@@ -367,7 +367,7 @@ _DC_read_message(char *box, char *name, int del_msg)
if ((f= fopen(fn, "r")) != NULL)
{
int bs= 100, i;
char c;
int c;
buf= malloc(bs);
i= 0;
......@@ -379,10 +379,10 @@ _DC_read_message(char *box, char *name, int del_msg)
bs+= 100;
buf= realloc(buf, bs);
}
buf[i]= c;
buf[i]= (char)c;
i++;
buf[i]= '\0';
}
buf[i]= '\0';
fclose(f);
if (del_msg)
unlink(fn);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment