Revision: 41196
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41196&view=rev
Author:   brlcad
Date:     2010-10-30 00:08:34 +0000 (Sat, 30 Oct 2010)

Log Message:
-----------
cleanup, return from funcs that return, deshadow

Modified Paths:
--------------
    brlcad/trunk/src/fb/bw-fb.c
    brlcad/trunk/src/fb/cell-fb.c

Modified: brlcad/trunk/src/fb/bw-fb.c
===================================================================
--- brlcad/trunk/src/fb/bw-fb.c 2010-10-30 00:00:30 UTC (rev 41195)
+++ brlcad/trunk/src/fb/bw-fb.c 2010-10-30 00:08:34 UTC (rev 41196)
@@ -45,33 +45,33 @@
 
 int skipbytes(int fd, off_t num);
 
-#define        MAX_LINE        (16*1024)       /* Largest output scan line 
length */
+#define MAX_LINE (16*1024)     /* Largest output scan line length */
 
-static char    ibuf[MAX_LINE];
+static char ibuf[MAX_LINE];
 static RGBpixel obuf[MAX_LINE];
 
-static int     fileinput = 0;          /* file of pipe on input? */
-static int     autosize = 0;           /* !0 to autosize input */
+static int fileinput = 0;              /* file of pipe on input? */
+static int autosize = 0;               /* !0 to autosize input */
 
-static unsigned long int       file_width = 512;       /* default input width 
*/
-static unsigned long int       file_height = 512;      /* default input height 
*/
-static int     scr_width = 0;          /* screen tracks file if not given */
-static int     scr_height = 0;
-static int     file_xoff, file_yoff;
-static int     scr_xoff, scr_yoff;
-static int     clear = 0;
-static int     zoom = 0;
-static int     inverse = 0;
-static int     redflag   = 0;
-static int     greenflag = 0;
-static int     blueflag  = 0;
+static unsigned long int file_width = 512;     /* default input width */
+static unsigned long int file_height = 512;    /* default input height */
+static int scr_width = 0;              /* screen tracks file if not given */
+static int scr_height = 0;
+static int file_xoff, file_yoff;
+static int scr_xoff, scr_yoff;
+static int clear = 0;
+static int zoom = 0;
+static int inverse = 0;
+static int redflag   = 0;
+static int greenflag = 0;
+static int blueflag  = 0;
 
-static char    *framebuffer = NULL;
-static char    *file_name;
-static int     infd;
-static FBIO    *fbp;
+static char *framebuffer = NULL;
+static char *file_name;
+static int infd;
+static FBIO *fbp;
 
-static char    usage[] = "\
+static char usage[] = "\
 Usage: bw-fb [-a -h -i -c -z -R -G -B] [-F framebuffer]\n\
        [-s squarefilesize] [-w file_width] [-n file_height]\n\
        [-x file_xoff] [-y file_yoff] [-X scr_xoff] [-Y scr_yoff]\n\
@@ -175,10 +175,11 @@
     return 1;          /* OK */
 }
 
+
 int
 main(int argc, char **argv)
 {
-    int        x, y, n;
+    int x, y, n;
     long xout, yout;           /* number of sceen output lines */
     long xstart, xskip;
 
@@ -189,7 +190,7 @@
 
     /* autosize input? */
     if (fileinput && autosize) {
-       unsigned long int       w, h;
+       unsigned long int w, h;
        if (fb_common_file_size(&w, &h, file_name, 1)) {
            file_width = w;
            file_height = h;
@@ -219,14 +220,11 @@
     scr_height = fb_getheight(fbp);
 
     /* compute pixels output to screen */
-    if (scr_xoff < 0)
-    {
+    if (scr_xoff < 0) {
        xout = scr_width + scr_xoff;
        xskip = (-scr_xoff);
        xstart = 0;
-    }
-    else
-    {
+    } else {
        xout = scr_width - scr_xoff;
        xskip = 0;
        xstart = scr_xoff;
@@ -244,7 +242,7 @@
        yout = (file_height-file_yoff);
     if (xout > MAX_LINE) {
        fprintf(stderr, "bw-fb: can't output %ld pixel lines.\n", xout);
-       bu_exit(2, NULL);
+       return 2;
     }
 
     if (clear) {
@@ -261,8 +259,8 @@
 
     /* Test for simplest case */
     if (inverse == 0 && file_xoff == 0 && file_yoff == 0 && 
scr_xoff+file_width <= (unsigned)fb_getwidth(fbp)) {
-       unsigned char   *buf;
-       int             npix = file_width * yout;
+       unsigned char *buf;
+       int npix = file_width * yout;
 
        if ((buf = malloc(npix)) == NULL) {
            perror("bw-fb malloc");
@@ -271,7 +269,8 @@
        n = bu_mread(infd, (char *)buf, npix);
        if (n != npix) {
            fprintf(stderr, "bw-fb: read got %d, s/b %d\n", n, npix);
-           if (n <= 0)  bu_exit(7, NULL);
+           if (n <= 0)
+               return 7;
            npix = n;   /* show what we got */
        }
        n = (npix+file_width-1)/file_width;     /* num lines got */
@@ -281,16 +280,15 @@
            bu_exit(8, NULL);
        }
        fb_close(fbp);
-       bu_exit(0, NULL);
+       return 0;
     }
 
     /* Begin general case */
- general:
+general:
     if (file_yoff != 0) skipbytes(infd, file_yoff*file_width);
 
     for (y = scr_yoff; y < scr_yoff + yout; y++) {
-       if (y < 0 || y >= scr_height)
-       {
+       if (y < 0 || y >= scr_height) {
            skipbytes(infd, file_width);
            continue;
        }
@@ -309,7 +307,7 @@
            else
                n = fb_read(fbp, scr_xoff, y,
                            (unsigned char *)obuf, xout);
-           if (n < 0)  break;
+           if (n < 0) break;
        }
        for (x = 0; x < xout; x++) {
            if (redflag)
@@ -330,16 +328,17 @@
     }
 
     fb_close(fbp);
-    bu_exit(0, NULL);
+    return 0;
 }
 
+
 /*
  * Throw bytes away.  Use reads into ibuf buffer if a pipe, else seek.
  */
 int
 skipbytes(int fd, off_t num)
 {
-    int        n, try;
+    int n, try;
 
     if (fileinput) {
        (void)lseek(fd, num, 1);
@@ -354,9 +353,10 @@
        }
        num -= n;
     }
-    return     0;
+    return 0;
 }
 
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/fb/cell-fb.c
===================================================================
--- brlcad/trunk/src/fb/cell-fb.c       2010-10-30 00:00:30 UTC (rev 41195)
+++ brlcad/trunk/src/fb/cell-fb.c       2010-10-30 00:08:34 UTC (rev 41196)
@@ -448,7 +448,7 @@
     static RGBpixel    pixel;
     double             lasty = NEG_INFINITY;
     double             dx, dy;
-    int        y0 = 0, y1;
+    int        y_0 = 0, y_1;
 
     if (compute_fb_height)
     {
@@ -506,12 +506,12 @@
            {
                if (debug_flag & CFB_DBG_GRID)
                    bu_log("%g = V2SCRY(%g)\n", V2SCRY(lasty), lasty);
-               y0 = V2SCRY(lasty);
-               if ( y0 >= 0 && y0 < fb_height )  {
-                   for (y1 = y0 + hgt; y0 < y1; y0++)
-                       if (fb_write(fbiop, 0, y0, buf, fb_width) == -1)
+               y_0 = V2SCRY(lasty);
+               if ( y_0 >= 0 && y_0 < fb_height )  {
+                   for (y_1 = y_0 + hgt; y_0 < y_1; y_0++)
+                       if (fb_write(fbiop, 0, y_0, buf, fb_width) == -1)
                        {
-                           bu_log("Couldn't write to <%d,%d>\n", 0, y0);
+                           bu_log("Couldn't write to <%d,%d>\n", 0, y_0);
                            (void) fb_close(fbiop);
                            return false;
                        }
@@ -526,14 +526,14 @@
            /* Draw grid line between rows of cells. */
            if (grid_flag && (lasty != NEG_INFINITY))
            {
-               if (fb_write(fbiop, 0, y0, buf, fb_width) == -1)
+               if (fb_write(fbiop, 0, y_0, buf, fb_width) == -1)
                {
-                   bu_log("Couldn't write to <%d,%d>\n", 0, y0);
+                   bu_log("Couldn't write to <%d,%d>\n", 0, y_0);
                    (void) fb_close(fbiop);
                    return false;
                }
                if (debug_flag & CFB_DBG_GRID)
-                   bu_log("Writing grid row at %d\n", y0);
+                   bu_log("Writing grid row at %d\n", y_0);
            }
            lasty = gp->c_y;
        }
@@ -551,10 +551,10 @@
     /* Write out last row of cells. */
     if (debug_flag & CFB_DBG_GRID)
        bu_log("%g = V2SCRY(%g)\n", V2SCRY(lasty), lasty);
-    for (y0 = V2SCRY(lasty), y1 = y0 + hgt; y0 < y1;  y0++)
-       if (fb_write(fbiop, 0, y0, buf, fb_width) == -1)
+    for (y_0 = V2SCRY(lasty), y_1 = y_0 + hgt; y_0 < y_1;  y_0++)
+       if (fb_write(fbiop, 0, y_0, buf, fb_width) == -1)
        {
-           bu_log("Couldn't write to <%d,%d>\n", 0, y0);
+           bu_log("Couldn't write to <%d,%d>\n", 0, y_0);
            (void) fb_close(fbiop);
            return false;
        }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to