Commit b8fb9e5be06275d2bb8d43d8b7b92c795678be58
authorMichel Pollet <buserror@gmail.com>
Wed, 20 Jun 2018 08:13:16 +0000 (09:13 +0100)
committerMichel Pollet <buserror@gmail.com>
Wed, 20 Jun 2018 08:13:16 +0000 (09:13 +0100)
Mostly intenting.

Signed-off-by: Michel Pollet <buserror@gmail.com>
11 files changed:
examples/board_hd44780/charlcd.c
examples/parts/uart_pty.c
examples/parts/uart_pty.h
simavr/sim/avr_timer.c
simavr/sim/avr_twi.c
simavr/sim/avr_usb.c
simavr/sim/sim_elf.c
simavr/sim/sim_gdb.c
simavr/sim/sim_interrupts.c
simavr/sim/sim_network.h
simavr/sim/sim_vcd_file.c

index 24f70f9d5944a1d7503f1f50a499ff9a39c49ecc..100cd34c121430dcd87ad398604af87b84997320 100644 (file)
@@ -100,7 +100,7 @@ void displayCB(void)                /* function called whenever redisplay needed */
                        colors[color][2], /* text */
                        colors[color][3] /* shadow */ );
        glPopMatrix();
-    glutSwapBuffers();
+       glutSwapBuffers();
 }
 
 // gl timer. if the lcd is dirty, refresh display
@@ -164,7 +164,7 @@ main(
        avr_load_firmware(avr, &f);
        ac_input_init(avr, &ac_input);
        avr_connect_irq(ac_input.irq + IRQ_AC_OUT, avr_io_getirq(avr,
-               AVR_IOCTL_IOPORT_GETIRQ('D'), 2));
+                       AVR_IOCTL_IOPORT_GETIRQ('D'), 2));
 
        hd44780_init(avr, &hd44780, 20, 4);
 
index 4f4edd0826453a37ae8af1feb01f3575d3c17e3a..632dbdc4d83ef33a33cd956619adbcea57c7b788 100644 (file)
@@ -209,8 +209,10 @@ uart_pty_thread(
                                // write them in fifo
                                uint8_t * dst = buffer;
                                while (!uart_pty_fifo_isempty(&p->port[ti].in) &&
-                                               dst < (buffer + sizeof(buffer)))
-                                       *dst++ = uart_pty_fifo_read(&p->port[ti].in);
+                                               (dst - buffer) < sizeof(buffer)) {
+                                       *dst = uart_pty_fifo_read(&p->port[ti].in);
+                                       dst++;
+                               }
                                size_t len = dst - buffer;
                                TRACE(size_t r =) write(p->port[ti].s, buffer, len);
                                TRACE(if (!p->port[ti].tap) hdump("pty send", buffer, r);)
index c6e0603aada6791457c567ae8e3e0676c062b4b7..a75f9f5b25f63d5ceb440a4cab130996763a7fad 100644 (file)
@@ -36,7 +36,7 @@ enum {
 DECLARE_FIFO(uint8_t,uart_pty_fifo, 512);
 
 typedef struct uart_pty_port_t {
-       int                     tap : 1, crlf : 1;
+       unsigned int    tap : 1, crlf : 1;
        int             s;                      // socket we chat on
        char            slavename[64];
        uart_pty_fifo_t in;
index c05c7ebc7b2a91f784776103cc03883054e51118..3fcfd8b8554adf8caaafefbc75e8cf97438b7262 100644 (file)
@@ -41,8 +41,8 @@ _timer_get_ocr(
                int compi)
 {
        return p->io.avr->data[p->comp[compi].r_ocr] |
-                     (p->comp[compi].r_ocrh ?
-                                 (p->io.avr->data[p->comp[compi].r_ocrh] << 8) : 0);
+                         (p->comp[compi].r_ocrh ?
+                                         (p->io.avr->data[p->comp[compi].r_ocrh] << 8) : 0);
 }
 
 static uint16_t
@@ -720,7 +720,7 @@ avr_timer_write_pending(
                cp[compi] = avr_regbit_get(avr, p->comp[compi].interrupt.raised);
 
        // write the value
-    // avr_core_watch_write(avr, addr, v); // This raises flags instead of clearing it.
+       // avr_core_watch_write(avr, addr, v); // This raises flags instead of clearing it.
 
        // clear any interrupts & flags
        avr_clear_interrupt_if(avr, &p->overflow, ov);
index 8249ee72e238465a015a49b8370078da2ca551d4..5e351e53b41dae1f3fa095d0d1b5311c9043fc18 100644 (file)
@@ -170,7 +170,8 @@ avr_twi_write(
 
        uint8_t cleared = avr_regbit_get(avr, p->twi.raised);
 
-       /*int cleared = */avr_clear_interrupt_if(avr, &p->twi, twint);
+       /*int cleared = */
+       avr_clear_interrupt_if(avr, &p->twi, twint);
 //     AVR_TRACE(avr, "cleared %d\n", cleared);
 
        if (!twsto && avr_regbit_get(avr, p->twsto)) {
index d87aca5ea850931e536e6d7ec7abc6d0e50f92f1..4acbcfdd1a84db20a92ce30093769fdf6ed2da4e 100644 (file)
@@ -372,7 +372,8 @@ ep_fifo_usb_write(
        if (len > ep_fifo_size(epstate)) {
                printf("EP OVERFI\n");
                len = sizeof epstate->bank[epstate->current_bank].bytes;
-       }memcpy(epstate->bank[epstate->current_bank].bytes, buf, len);
+       }
+       memcpy(epstate->bank[epstate->current_bank].bytes, buf, len);
        epstate->bank[epstate->current_bank].tail = len;
 
        return 0;
index f2f1a154b52a4e135bd7f912ffb6503f5640a1f9..4c289593152af2373b53d2abd56d90cd93f9e209 100644 (file)
@@ -434,10 +434,10 @@ elf_read_firmware(
        if (data_fuse) {
                if (elf_copy_section(".fuse", data_fuse, &firmware->fuse))
                        return -1;
-        firmware->fusesize = data_fuse->d_size;
+               firmware->fusesize = data_fuse->d_size;
        }
        if (data_lockbits) {
-               if (elf_copy_section(".lock", data_fuse, &firmware->lockbits))
+               if (elf_copy_section(".lock", data_lockbits, &firmware->lockbits))
                        return -1;
        }
 //     hdump("flash", avr->flash, offset);
index c706b2a01d5af7b9dda0ca2d124894fc33aaca6a..de89b1c699fa31266533de0f09d7557e4979d263 100644 (file)
@@ -320,7 +320,7 @@ gdb_handle_command(
 
                                gdb_send_reply(g, rep);
                                break;
-            }
+                       }
                        gdb_send_reply(g, "");
                        break;
                case '?':
@@ -504,8 +504,8 @@ gdb_network_handler(
                        sleep(5);
                        return 1;
                }
-        int i = 1;
-        setsockopt (g->s, IPPROTO_TCP, TCP_NODELAY, &i, sizeof (i));
+               int i = 1;
+               setsockopt (g->s, IPPROTO_TCP, TCP_NODELAY, &i, sizeof (i));
                g->avr->state = cpu_Stopped;
                printf("%s connection opened\n", __FUNCTION__);
        }
index b689a94ea9ef75797f7bb91497bf1587ccef84f4..2791544277ff997c345dae5c7e227318f02354e1 100644 (file)
@@ -271,7 +271,7 @@ avr_service_interrupts(
                vector->pending = 0;
                avr->interrupt_state = avr_has_pending_interrupts(avr);
        } else {
-               if (vector && vector->trace)
+               if (vector->trace)
                        printf("IRQ%d calling\n", vector->vector);
                _avr_push_addr(avr, avr->pc);
                avr_sreg_set(avr, S_I, 0);
index a43e1d8a167a3aa61c5c165c0cd2d3f09ead7bd0..b3e0fb3891f2142cf4a48f63f891dec4a6c8cda6 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
        (ssize_t)recv( (sockfd), (char *)(buf), (len), (flags))
 #define sleep(x) Sleep((x)*1000)
 
-static inline int network_init()
+static inline int network_init(void)
 {
        // Windows requires WinSock to be init before use
        WSADATA wsaData;
@@ -52,7 +52,7 @@ static inline int network_init()
        return 0;
 }
 
-static inline void network_release()
+static inline void network_release(void)
 {
        // close WinSock
        WSACleanup();
@@ -69,13 +69,13 @@ static inline void network_release()
 #include <sys/time.h>
 #include <poll.h>
 
-static inline int network_init()
+static inline int network_init(void)
 {
        // nothing to do
        return 0;
 }
 
-static inline void network_release()
+static inline void network_release(void)
 {
        // nothing to do
 }
index 9320a9f12fc809e32705a7b41a44871094312618..c0d27674341d9d09ad82c1ff468ba990b94ff67b 100644 (file)
@@ -265,13 +265,14 @@ avr_vcd_init_input(
 
                if (!strcmp(keyword, "$timescale")) {
                        double cnt = 0;
-                       vcd->vcd_to_us = 1;
                        char *si = v->argv[1];
+
+                       vcd->vcd_to_us = 1;
                        while (si && *si && isdigit(*si))
                                cnt = (cnt * 10) + (*si++ - '0');
-                       while (*si == ' ')
+                       while (si && *si == ' ')
                                si++;
-                       if (!*si)
+                       if (si && !*si)
                                si = v->argv[2];
                //      if (!strcmp(si, "ns")) // TODO: Check that,
                //              vcd->vcd_to_us = cnt;