Selaa lähdekoodia

* Fix warnings in compile utils

Bryan Drewery 17 vuotta sitten
vanhempi
commit
fbce4d23b3
3 muutettua tiedostoa jossa 9 lisäystä ja 7 poistoa
  1. 1 2
      src/makehelp.c
  2. 1 2
      src/makeres.c
  3. 7 3
      src/stringfix.c

+ 1 - 2
src/makehelp.c

@@ -44,8 +44,7 @@ char *step_thru_file(FILE *fd)
   }
   retStr = NULL;
   while (!feof(fd)) {
-    fgets(tempBuf, sizeof(tempBuf), fd);
-    if (!feof(fd)) {
+    if (fgets(tempBuf, sizeof(tempBuf), fd) && !feof(fd)) {
       if (retStr == NULL) {
         retStr = (char *) calloc(1, strlen(tempBuf) + 2);
         strcpy(retStr, tempBuf);

+ 1 - 2
src/makeres.c

@@ -60,8 +60,7 @@ char *step_thru_file(FILE *fd)
   }
   retStr = NULL;
   while (!feof(fd)) {
-    fgets(tempBuf, sizeof(tempBuf), fd);
-    if (!feof(fd)) {
+    if (fgets(tempBuf, sizeof(tempBuf), fd) && !feof(fd)) {
       if (retStr == NULL) {
         retStr = (char *) calloc(1, strlen(tempBuf) + 2);
         strcpy(retStr, tempBuf);

+ 7 - 3
src/stringfix.c

@@ -103,7 +103,7 @@ void processline(char *line)
   char tmpin[WTF] = "", tmpout[WTF] = "", *in = NULL, *out = NULL;
 
   strcpy(tmpin, line); 
-  memset((char *) &tmpin[strlen(tmpin)], 20, 0);
+  memset((char *) &tmpin[strlen(tmpin)], 0, 20);
   in = tmpin;
   out = tmpout;
   if (*in) {
@@ -144,7 +144,9 @@ int main(int argc, char *argv[])
   insize = ftell(f);
   fseek(f, 0, SEEK_SET);
   buf = (char *) calloc(1, insize + 1);
-  fread(buf, 1, insize, f);
+  if (!fread(buf, 1, insize, f)) {
+    ;
+  }
   fclose(f);
   buf[insize] = 0;
 
@@ -159,7 +161,9 @@ int main(int argc, char *argv[])
   }
 
   if ((f = fopen(argv[2], "w"))) {
-    fwrite(outbuf, strlen(outbuf), 1, f);
+    if (!fwrite(outbuf, strlen(outbuf), 1, f)) {
+      ;
+    }
     fclose(f);
   }
   /*  printf(outbuf); */