Commit 3785ed26321f11918908fe65b7a00aa218d9e80a

Authored by Loic Dachary
1 parent 63ffdaad
Exists in master

decoder/encoder: fix compilation warnings

Resolve compilation warnings about unused variables and function return
values being ignored.

Signed-off-by: Loic Dachary <loic@dachary.org>
Showing 2 changed files with 7 additions and 7 deletions   Show diff stats
Examples/decoder.c
... ... @@ -62,6 +62,7 @@ same arguments, and encoder.c does error check.
62 62 #include <stdlib.h>
63 63 #include <string.h>
64 64 #include <time.h>
  65 +#include <assert.h>
65 66 #include <unistd.h>
66 67 #include <sys/time.h>
67 68 #include <sys/stat.h>
... ... @@ -104,12 +105,11 @@ int main (int argc, char **argv) {
104 105 char *c_tech;
105 106  
106 107 int i, j; // loop control variable, s
107   - int blocksize; // size of individual files
  108 + int blocksize = 0; // size of individual files
108 109 int origsize; // size of file before padding
109 110 int total; // used to write data, not padding to file
110 111 struct stat status; // used to find size of individual files
111 112 int numerased; // number of erased files
112   - int dummy;
113 113  
114 114 /* Used to recreate file names */
115 115 char *temp;
... ... @@ -270,11 +270,11 @@ int main (int argc, char **argv) {
270 270 stat(fname, &status);
271 271 blocksize = status.st_size;
272 272 data[i-1] = (char *)malloc(sizeof(char)*blocksize);
273   - dummy = fread(data[i-1], sizeof(char), blocksize, fp);
  273 + assert(blocksize == fread(data[i-1], sizeof(char), blocksize, fp));
274 274 }
275 275 else {
276 276 fseek(fp, blocksize*(n-1), SEEK_SET);
277   - dummy = fread(data[i-1], sizeof(char), buffersize/k, fp);
  277 + assert(buffersize/k == fread(data[i-1], sizeof(char), buffersize/k, fp));
278 278 }
279 279 fclose(fp);
280 280 }
... ... @@ -293,11 +293,11 @@ int main (int argc, char **argv) {
293 293 stat(fname, &status);
294 294 blocksize = status.st_size;
295 295 coding[i-1] = (char *)malloc(sizeof(char)*blocksize);
296   - dummy = fread(coding[i-1], sizeof(char), blocksize, fp);
  296 + assert(blocksize == fread(coding[i-1], sizeof(char), blocksize, fp));
297 297 }
298 298 else {
299 299 fseek(fp, blocksize*(n-1), SEEK_SET);
300   - dummy = fread(coding[i-1], sizeof(char), blocksize, fp);
  300 + assert(blocksize == fread(coding[i-1], sizeof(char), blocksize, fp));
301 301 }
302 302 fclose(fp);
303 303 }
... ...
Examples/encoder.c
... ... @@ -326,7 +326,7 @@ int main (int argc, char **argv) {
326 326  
327 327 /* Get current working directory for construction of file names */
328 328 curdir = (char*)malloc(sizeof(char)*1000);
329   - getcwd(curdir, 1000);
  329 + assert(curdir == getcwd(curdir, 1000));
330 330  
331 331 if (argv[1][0] != '-') {
332 332  
... ...