summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Plank <plank@cs.utk.edu>2014-02-07 12:12:54 -0500
committerJim Plank <plank@cs.utk.edu>2014-02-07 12:12:54 -0500
commitc21f772f11fb3c25f6ba4c389be3a126e43734d0 (patch)
treefb2afb6d751c6348ffcd47852d12012b10f9bd61
parent8a85c829d6c346122b4059f057833b7a61b7f00f (diff)
downloadjerasure-c21f772f11fb3c25f6ba4c389be3a126e43734d0.tar.gz
Fixed some compiler warnings.
-rw-r--r--Examples/decoder.c32
-rw-r--r--Examples/encoder.c1
2 files changed, 24 insertions, 9 deletions
diff --git a/Examples/decoder.c b/Examples/decoder.c
index e6e9219..b01e538 100644
--- a/Examples/decoder.c
+++ b/Examples/decoder.c
@@ -61,6 +61,7 @@ same arguments, and encoder.c does error check.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <signal.h>
@@ -99,12 +100,13 @@ int main (int argc, char **argv) {
int tech;
char *c_tech;
- int i, j; // loop control variables
+ int i, j; // loop control variable, s
int blocksize; // size of individual files
int origsize; // size of file before padding
int total; // used to write data, not padding to file
struct stat status; // used to find size of individual files
int numerased; // number of erased files
+ int dummy;
/* Used to recreate file names */
char *temp;
@@ -165,7 +167,10 @@ int main (int argc, char **argv) {
exit(1);
}
temp = (char *)malloc(sizeof(char)*(strlen(argv[1])+20));
- fscanf(fp, "%s", temp);
+ if (fscanf(fp, "%s", temp) != 1) {
+ fprintf(stderr, "Metadata file - bad format\n");
+ exit(0);
+ }
if (fscanf(fp, "%d", &origsize) != 1) {
fprintf(stderr, "Original size is not valid\n");
@@ -176,10 +181,19 @@ int main (int argc, char **argv) {
exit(0);
}
c_tech = (char *)malloc(sizeof(char)*(strlen(argv[1])+20));
- fscanf(fp, "%s", c_tech);
- fscanf(fp, "%d", &tech);
+ if (fscanf(fp, "%s", c_tech) != 1) {
+ fprintf(stderr, "Metadata file - bad format\n");
+ exit(0);
+ }
+ if (fscanf(fp, "%d", &tech) != 1) {
+ fprintf(stderr, "Metadata file - bad format\n");
+ exit(0);
+ }
method = tech;
- fscanf(fp, "%d", &readins);
+ if (fscanf(fp, "%d", &readins) != 1) {
+ fprintf(stderr, "Metadata file - bad format\n");
+ exit(0);
+ }
fclose(fp);
/* Allocate memory */
@@ -260,11 +274,11 @@ int main (int argc, char **argv) {
stat(fname, &status);
blocksize = status.st_size;
data[i-1] = (char *)malloc(sizeof(char)*blocksize);
- fread(data[i-1], sizeof(char), blocksize, fp);
+ dummy = fread(data[i-1], sizeof(char), blocksize, fp);
}
else {
fseek(fp, blocksize*(n-1), SEEK_SET);
- fread(data[i-1], sizeof(char), buffersize/k, fp);
+ dummy = fread(data[i-1], sizeof(char), buffersize/k, fp);
}
fclose(fp);
}
@@ -283,11 +297,11 @@ int main (int argc, char **argv) {
stat(fname, &status);
blocksize = status.st_size;
coding[i-1] = (char *)malloc(sizeof(char)*blocksize);
- fread(coding[i-1], sizeof(char), blocksize, fp);
+ dummy = fread(coding[i-1], sizeof(char), blocksize, fp);
}
else {
fseek(fp, blocksize*(n-1), SEEK_SET);
- fread(coding[i-1], sizeof(char), blocksize, fp);
+ dummy = fread(coding[i-1], sizeof(char), blocksize, fp);
}
fclose(fp);
}
diff --git a/Examples/encoder.c b/Examples/encoder.c
index 1b76af9..6e01acf 100644
--- a/Examples/encoder.c
+++ b/Examples/encoder.c
@@ -55,6 +55,7 @@ is the file name with "_k#" or "_m#" and then the extension.
(For example, inputfile test.txt would yield file "test_k1.txt".)
*/
+#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <string.h>