]> git-server-git.apps.pok.os.sepia.ceph.com Git - jerasure.git/commitdiff
Fixed some compiler warnings.
authorJim Plank <plank@cs.utk.edu>
Fri, 7 Feb 2014 17:12:54 +0000 (12:12 -0500)
committerJim Plank <plank@cs.utk.edu>
Fri, 7 Feb 2014 17:12:54 +0000 (12:12 -0500)
Examples/decoder.c
Examples/encoder.c

index e6e921904b604e9b8b48fdc7a65d4f187adddaf7..b01e538b10a6019babc0d293be367c9051be4741 100644 (file)
@@ -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 variables
        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);
                        }
index 1b76af9fb3772c828b419e222a639cb8dd10d0d1..6e01acfb18590b816e050dbcef3da323689403e8 100644 (file)
@@ -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>