[CRISv10] Clean up compressed/misc.c
authorJesper Nilsson <jesper@jni.nu>
Mon, 30 Jun 2008 19:20:23 +0000 (21:20 +0200)
committerJesper Nilsson <jesper@jni.nu>
Mon, 30 Jun 2008 21:57:25 +0000 (23:57 +0200)
Many minor fixes in whitespace and formatting.

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
arch/cris/arch-v10/boot/compressed/misc.c

index 59961f2..18e13bc 100644 (file)
 #define OF(args)  args
 #define STATIC static
 
-void* memset(void* s, int c, size_t n);
-void* memcpy(void* __dest, __const void* __src, size_t __n);
-
-#define memzero(s, n)     memset ((s), 0, (n))
+void *memset(void *s, int c, size_t n);
+void *memcpy(void *__dest, __const void *__src, size_t __n);
 
+#define memzero(s, n)     memset((s), 0, (n))
 
 typedef unsigned char  uch;
 typedef unsigned short ush;
@@ -61,23 +60,38 @@ static unsigned outcnt = 0;  /* bytes in output buffer */
 #define ENCRYPTED    0x20 /* bit 5 set: file is encrypted */
 #define RESERVED     0xC0 /* bit 6,7:   reserved */
 
-#define get_byte() inbuf[inptr++]      
-       
+#define get_byte() (inbuf[inptr++])
+
 /* Diagnostic functions */
 #ifdef DEBUG
-#  define Assert(cond,msg) {if(!(cond)) error(msg);}
+#  define Assert(cond, msg) do { \
+               if (!(cond)) \
+                       error(msg); \
+       } while (0)
 #  define Trace(x) fprintf x
-#  define Tracev(x) {if (verbose) fprintf x ;}
-#  define Tracevv(x) {if (verbose>1) fprintf x ;}
-#  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
-#  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
+#  define Tracev(x) do { \
+               if (verbose) \
+                       fprintf x; \
+       } while (0)
+#  define Tracevv(x) do { \
+               if (verbose > 1) \
+                       fprintf x; \
+       } while (0)
+#  define Tracec(c, x) do { \
+               if (verbose && (c)) \
+                       fprintf x; \
+       } while (0)
+#  define Tracecv(c, x) do { \
+               if (verbose > 1 && (c)) \
+                       fprintf x; \
+       } while (0)
 #else
-#  define Assert(cond,msg)
+#  define Assert(cond, msg)
 #  define Trace(x)
 #  define Tracev(x)
 #  define Tracevv(x)
-#  define Tracec(c,x)
-#  define Tracecv(c,x)
+#  define Tracec(c, x)
+#  define Tracecv(c, x)
 #endif
 
 static void flush_window(void);
@@ -88,26 +102,27 @@ extern char *input_data;  /* lives in head.S */
 static long bytes_out = 0;
 static uch *output_data;
 static unsigned long output_ptr = 0;
+
 static void *malloc(int size);
 static void free(void *where);
 static void gzip_mark(void **);
 static void gzip_release(void **);
+
 static void puts(const char *);
 
 /* the "heap" is put directly after the BSS ends, at end */
-  
+
 extern int _end;
 static long free_mem_ptr = (long)&_end;
+
 #include "../../../../../lib/inflate.c"
 
 static void *malloc(int size)
 {
        void *p;
 
-       if (size <0) error("Malloc error");
+       if (size < 0)
+               error("Malloc error");
 
        free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
 
@@ -137,48 +152,47 @@ static void
 puts(const char *s)
 {
 #ifndef CONFIG_ETRAX_DEBUG_PORT_NULL
-       while(*s) {
+       while (*s) {
 #ifdef CONFIG_ETRAX_DEBUG_PORT0
-               while(!(*R_SERIAL0_STATUS & (1 << 5))) ;
+               while (!(*R_SERIAL0_STATUS & (1 << 5))) ;
                *R_SERIAL0_TR_DATA = *s++;
 #endif
 #ifdef CONFIG_ETRAX_DEBUG_PORT1
-               while(!(*R_SERIAL1_STATUS & (1 << 5))) ;
+               while (!(*R_SERIAL1_STATUS & (1 << 5))) ;
                *R_SERIAL1_TR_DATA = *s++;
 #endif
 #ifdef CONFIG_ETRAX_DEBUG_PORT2
-               while(!(*R_SERIAL2_STATUS & (1 << 5))) ;
+               while (!(*R_SERIAL2_STATUS & (1 << 5))) ;
                *R_SERIAL2_TR_DATA = *s++;
 #endif
 #ifdef CONFIG_ETRAX_DEBUG_PORT3
-               while(!(*R_SERIAL3_STATUS & (1 << 5))) ;
+               while (!(*R_SERIAL3_STATUS & (1 << 5))) ;
                *R_SERIAL3_TR_DATA = *s++;
 #endif
        }
 #endif
 }
 
-void*
-memset(void* s, int c, size_t n)
+void *memset(void *s, int c, size_t n)
 {
        int i;
-       char *ss = (char*)s;
+       char *ss = (char *)s;
 
-       for (i=0;i<n;i++) ss[i] = c;
+       for (i = 0; i < n; i++)
+               ss[i] = c;
 
-   return s;
+       return s;
 }
 
-void*
-memcpy(void* __dest, __const void* __src,
-                           size_t __n)
+void *memcpy(void *__dest, __const void *__src, size_t __n)
 {
        int i;
        char *d = (char *)__dest, *s = (char *)__src;
 
-       for (i=0;i<__n;i++) d[i] = s[i];
+       for (i = 0; i < __n; i++)
+               d[i] = s[i];
 
-   return __dest;
+       return __dest;
 }
 
 /* ===========================================================================
@@ -186,33 +200,33 @@ memcpy(void* __dest, __const void* __src,
  * (Used for the decompressed data only.)
  */
 
-static void
-flush_window()
+static void flush_window(void)
 {
-    ulg c = crc;         /* temporary variable */
-    unsigned n;
-    uch *in, *out, ch;
-    
-    in = window;
-    out = &output_data[output_ptr]; 
-    for (n = 0; n < outcnt; n++) {
-           ch = *out++ = *in++;
-           c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
-    }
-    crc = c;
-    bytes_out += (ulg)outcnt;
-    output_ptr += (ulg)outcnt;
-    outcnt = 0;
+       ulg c = crc;         /* temporary variable */
+       unsigned n;
+       uch *in, *out, ch;
+
+       in = window;
+       out = &output_data[output_ptr];
+       for (n = 0; n < outcnt; n++) {
+               ch = *out = *in;
+               out++;
+               in++;
+               c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
+       }
+       crc = c;
+       bytes_out += (ulg)outcnt;
+       output_ptr += (ulg)outcnt;
+       outcnt = 0;
 }
 
-static void
-error(char *x)
+static void error(char *x)
 {
        puts("\n\n");
        puts(x);
        puts("\n\n -- System halted\n");
 
-       while(1);       /* Halt */
+       while (1);      /* Halt */
 }
 
 void setup_normal_output_buffer(void)
@@ -223,7 +237,7 @@ void setup_normal_output_buffer(void)
 void decompress_kernel(void)
 {
        char revision;
-       
+
        /* input_data is set in head.S */
        inbuf = input_data;
 
@@ -255,10 +269,9 @@ void decompress_kernel(void)
        makecrc();
 
        __asm__ volatile ("move $vr,%0" : "=rm" (revision));
-       if (revision < 10)
-       {
+       if (revision < 10) {
                puts("You need an ETRAX 100LX to run linux 2.6\n");
-               while(1);
+               while (1);
        }
 
        puts("Uncompressing Linux...\n");