sim/erc32: Removed type mismatch compiler warnings
authorJiri Gaisler <jiri@gaisler.se>
Tue, 17 Mar 2015 21:02:39 +0000 (22:02 +0100)
committerMike Frysinger <vapier@gentoo.org>
Tue, 17 Mar 2015 22:58:14 +0000 (18:58 -0400)
sim/erc32/ChangeLog
sim/erc32/func.c

index 253b450c89cfff6a00a88f9bdc5ce682d30ad919..3c4daa3c23992a3a204b9d862bdaa23feb4e8524 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-17  Jiri Gaisler  <jiri@gaisler.se>
+
+       * func.c (exec_cmd): Silence compiler warnings when calling system().
+       (batch): Replace fgets() with getline().
+
 2015-03-17  Jiri Gaisler  <jiri@gaisler.se>
 
        * func.c (show_stat): Print simulation time in portable long long
index 260ceff0f693069ac5cf7443742476f5d83421ec..265d42f5f162cdd18534250f8c2ba8668c0de49a 100644 (file)
@@ -80,20 +80,23 @@ batch(sregs, fname)
     char           *fname;
 {
     FILE           *fp;
-    char            lbuf[1024];
+    char           *lbuf = NULL;
+    size_t         len = 0;
+    size_t         slen;
 
     if ((fp = fopen(fname, "r")) == NULL) {
        fprintf(stderr, "couldn't open batch file %s\n", fname);
        return (0);
     }
-    while (!feof(fp)) {
-       lbuf[0] = 0;
-       fgets(lbuf, 1023, fp);
-       if ((strlen(lbuf) > 0) && (lbuf[strlen(lbuf) - 1] == '\n'))
-           lbuf[strlen(lbuf) - 1] = 0;
-       printf("sis> %s\n", lbuf);
-       exec_cmd(sregs, lbuf);
+    while (getline(&lbuf, &len, fp) > -1) {
+       slen = strlen(lbuf);
+       if (slen && (lbuf[slen - 1] == '\n')) {
+           lbuf[slen - 1] = 0;
+           printf("sis> %s\n", lbuf);
+           exec_cmd(sregs, lbuf);
+       }
     }
+    free(lbuf);
     fclose(fp);
     return (1);
 }
@@ -554,7 +557,9 @@ exec_cmd(sregs, cmd)
            sim_halt();
        } else if (strncmp(cmd1, "shell", clen) == 0) {
            if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) {
-               system(&cmdsave[clen]);
+               if (system(&cmdsave[clen])) {
+                   /* Silence unused return value warning.  */
+               }
            }
        } else if (strncmp(cmd1, "step", clen) == 0) {
            stat = run_sim(sregs, 1, 1);
This page took 0.026268 seconds and 4 git commands to generate.