Fix compiler warnings from GCC 8.1
authorStafford Horne <shorne@gmail.com>
Thu, 4 Oct 2018 14:07:48 +0000 (23:07 +0900)
committerStafford Horne <shorne@gmail.com>
Thu, 4 Oct 2018 14:07:48 +0000 (23:07 +0900)
Fix these 2 warnings:

 litex/build/sim/core/libdylib.c:42:5: warning: 'strncpy' specified bound 2048 equals destination size
 [-Wstringop-truncation]
     strncpy(last_err, s, ERR_MAX_SIZE);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 In function 'set_last_error',

 litex/soc/software/libbase/exception.c:28:13: warning: function declaration isn't a prototype [-Wstrict-prototypes]
  static char emerg_getc()

litex/build/sim/core/libdylib.c
litex/soc/software/libbase/exception.c

index ba8cdb6a0b1af05f718a66d673ef45f8ef77cfc7..aaf0822889e98115ed1a51693b2beaa58690430e 100644 (file)
@@ -39,7 +39,7 @@ static void set_last_error(const char *s)
     if (!s)
         s = "NULL error";
     last_err_set = 1;
-    strncpy(last_err, s, ERR_MAX_SIZE);
+    strncpy(last_err, s, ERR_MAX_SIZE-1);
 }
 
 static dylib_ref dylib_ref_alloc (void *handle, const char *path)
index b758e58eecfb52a5636fd485235cc996bddcb3a6..09b26399ae4f26faa186bc442984e9999ef875e1 100644 (file)
@@ -25,7 +25,7 @@ static void emerg_printf(const char *fmt, ...)
        }
 }
 
-static char emerg_getc()
+static char emerg_getc(void)
 {
        while(uart_rxempty_read());
        char c = uart_rxtx_read();