This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] sim/erc32: Removed type mismatch compiler warnings


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b9f9ea2f5dd6112e56b69f1cd9271c10b3b14ed8

commit b9f9ea2f5dd6112e56b69f1cd9271c10b3b14ed8
Author: Jiri Gaisler <jiri@gaisler.se>
Date:   Tue Mar 17 22:02:39 2015 +0100

    sim/erc32: Removed type mismatch compiler warnings

Diff:
---
 sim/erc32/ChangeLog |  5 +++++
 sim/erc32/func.c    | 23 ++++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/sim/erc32/ChangeLog b/sim/erc32/ChangeLog
index 253b450..3c4daa3 100644
--- a/sim/erc32/ChangeLog
+++ b/sim/erc32/ChangeLog
@@ -1,5 +1,10 @@
 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
 	format.
 	* help.c (usage): Update usage help print-out.
diff --git a/sim/erc32/func.c b/sim/erc32/func.c
index 260ceff..265d42f 100644
--- a/sim/erc32/func.c
+++ b/sim/erc32/func.c
@@ -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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]