From 51a3d56245da895dabad3ef28fb9d32fdedff719 Mon Sep 17 00:00:00 2001
From: arcanum <arcanum@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Thu, 28 Aug 2003 23:02:25 +0000
Subject: [PATCH]     * avr910.c:     * fileio.c:     * main.c:     * stk500.c:
     More code cleanup to remove warnings.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@352 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog |  8 +++++++
 avr910.c  |  2 +-
 fileio.c  |  2 +-
 main.c    |  6 ++----
 stk500.c  | 63 +++++++++++++++++++++++++++----------------------------
 5 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a224fc25..fdd87fe8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-08-28  Eric B. Weddington  <eric@ecentral.com>
+
+    * avr910.c:
+    * fileio.c:
+    * main.c:
+    * stk500.c:
+    More code cleanup to remove warnings.
+
 2003-08-27  Theodore A. Roth  <troth@openavr.org>
 
 	* main.c (update_progress_no_tty): Properly terminate progress. Also
diff --git a/avr910.c b/avr910.c
index ba4e73ba..069c50cb 100644
--- a/avr910.c
+++ b/avr910.c
@@ -503,7 +503,7 @@ static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
   unsigned int max_addr = n_bytes;
   unsigned int page_addr;
   int page_bytes = page_size;
-  int page_wr_cmd_pending;
+  int page_wr_cmd_pending = 0;
 
   avr910_write_setup(pgm, p, m);
 
diff --git a/fileio.c b/fileio.c
index 5f994e6b..5dd9f35e 100644
--- a/fileio.c
+++ b/fileio.c
@@ -691,7 +691,7 @@ int fileio_rbin(struct fioparms * fio,
 int fileio_imm(struct fioparms * fio,
                char * filename, FILE * f, unsigned char * buf, int size)
 {
-  int rc;
+  int rc = 0;
   char * e, * p;
   unsigned long b;
   int loc;
diff --git a/main.c b/main.c
index d1b912de..cf6a8ca1 100644
--- a/main.c
+++ b/main.c
@@ -611,7 +611,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, int nowrite,
     /*
      * write the buffer contents to the selected memory type
      */
-    fprintf(stderr, "%s: writing %s (%d bytes):\n", 
+    fprintf(stderr, "%s: writing %s (%ld bytes):\n", 
             progname, upd->memtype, size);
 
     if (!nowrite) {
@@ -635,7 +635,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, int nowrite,
 
     vsize = rc;
 
-    fprintf(stderr, "%s: %d bytes of %s written\n", progname, 
+    fprintf(stderr, "%s: %ld bytes of %s written\n", progname, 
             vsize, upd->memtype);
 
   }
@@ -713,13 +713,11 @@ int main(int argc, char * argv [])
   int              exitrc;      /* exit code for main() */
   int              i;           /* general loop counter */
   int              ch;          /* options flag */
-  int              size;        /* size of memory region */
   int              len;         /* length for various strings */
   struct avrpart * p;           /* which avr part we are programming */
   struct avrpart * v;           /* used for verify */
   int              readorwrite; /* true if a chip read/write op was selected */
   int              ppidata;	/* cached value of the ppi data register */
-  int              vsize=-1;    /* number of bytes to verify */
   AVRMEM         * sig;         /* signature data */
   struct stat      sb;
   UPDATE         * upd;
diff --git a/stk500.c b/stk500.c
index 339a7186..f18a8895 100644
--- a/stk500.c
+++ b/stk500.c
@@ -934,41 +934,40 @@ static int stk500_set_fosc(PROGRAMMER * pgm, double v)
   };
   int idx, rc;
 
-  if (v <= 0.0) {
-    prescale = cmatch = 0;
-    goto setclock;
-  }
-  if (v > fbase / 2) {
-    const char *unit;
-    if (v > 1e6) {
-      v /= 1e6;
-      unit = "MHz";
-    } else if (v > 1e3) {
-      v /= 1e3;
-      unit = "kHz";
+  prescale = cmatch = 0;
+  if (v > 0.0) {
+    if (v > fbase / 2) {
+      const char *unit;
+      if (v > 1e6) {
+        v /= 1e6;
+        unit = "MHz";
+      } else if (v > 1e3) {
+        v /= 1e3;
+        unit = "kHz";
+      } else
+        unit = "Hz";
+      fprintf(stderr,
+          "%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n",
+          progname, v, unit, fbase / 2e6);
+      fosc = fbase / 2;
     } else
-      unit = "Hz";
-    fprintf(stderr,
-	    "%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n",
-	    progname, v, unit, fbase / 2e6);
-    fosc = fbase / 2;
-  } else
-    fosc = (unsigned)v;
-
-  for (idx = 0; idx < sizeof(ps) / sizeof(ps[0]); idx++) {
-    if (fosc >= fbase / (256 * ps[idx] * 2)) {
-      /* this prescaler value can handle our frequency */
-      prescale = idx + 1;
-      cmatch = (unsigned)(fbase / (2 * v * ps[idx]));
-      break;
+      fosc = (unsigned)v;
+    
+    for (idx = 0; idx < sizeof(ps) / sizeof(ps[0]); idx++) {
+      if (fosc >= fbase / (256 * ps[idx] * 2)) {
+        /* this prescaler value can handle our frequency */
+        prescale = idx + 1;
+        cmatch = (unsigned)(fbase / (2 * v * ps[idx]));
+        break;
+      }
+    }
+    if (idx == sizeof(ps) / sizeof(ps[0])) {
+      fprintf(stderr, "%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n",
+          progname, fosc, fbase / (256 * 1024 * 2));
+      return -1;
     }
   }
-  if (idx == sizeof(ps) / sizeof(ps[0])) {
-    fprintf(stderr, "%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n",
-	    progname, fosc, fbase / (256 * 1024 * 2));
-    return -1;
-  }
- setclock:
+  
   if ((rc = stk500_setparm(pgm, Parm_STK_OSC_PSCALE, prescale)) != 0
       || (rc = stk500_setparm(pgm, Parm_STK_OSC_CMATCH, cmatch)) != 0)
     return rc;