bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] [xen] Fix compiler warnings


From: Flavio Cruz
Subject: [PATCH] [xen] Fix compiler warnings
Date: Sat, 28 Jan 2023 01:02:25 -0500

* i386/xen/xen.c: Move failsafe_callback_regs to header file and include
  xen/xen.h
* xen/block.c: `name` must be const. Fix format string.
* xen/console.c: Move hyp_console_write and inline it in the header.
  Use static qualifier whenever possible. Cast to interrupt_handler_fn.
* xen/console.h: Define hyp_console_write as inline function.
* xen/evt.c: Avoid old style declaration and use interrupt_handler_fn.
* xen/evt.h: Use interrupt_handler_fn.
* xen/net.c: Use static. Use correct format and make `name` const.
* xen/time.c: Avoid old style declarations by adding void to the
  parameter list.
* xen/xen.c: Use static. Use interrupt_handler_fn. Delete `_hyp_halt`
  and `_hyp_todo`.
* xen/xen.h: Define hyp_failsafe_c_callback here to make sure we have
  the prototype.
---
 i386/xen/xen.c | 13 ++-----------
 xen/block.c    |  4 ++--
 xen/console.c  | 14 ++++----------
 xen/console.h  |  5 ++++-
 xen/evt.c      |  4 ++--
 xen/evt.h      |  2 +-
 xen/net.c      |  6 +++---
 xen/time.c     |  6 +++---
 xen/xen.c      | 15 ++-------------
 xen/xen.h      | 12 ++++++++++++
 10 files changed, 35 insertions(+), 46 deletions(-)

diff --git a/i386/xen/xen.c b/i386/xen/xen.c
index f2dedfb9..5309675f 100644
--- a/i386/xen/xen.c
+++ b/i386/xen/xen.c
@@ -23,20 +23,11 @@
 #include <mach/machine/eflags.h>
 #include <machine/thread.h>
 #include <machine/ipl.h>
-
 #include <machine/model_dep.h>
 
-unsigned long cr3;
+#include <xen/xen.h>
 
-struct failsafe_callback_regs {
-       unsigned int ds;
-       unsigned int es;
-       unsigned int fs;
-       unsigned int gs;
-       unsigned int ip;
-       unsigned int cs_and_mask;
-       unsigned int flags;
-};
+unsigned long cr3;
 
 void hyp_failsafe_c_callback(struct failsafe_callback_regs *regs) {
        printf("Fail-Safe callback!\n");
diff --git a/xen/block.c b/xen/block.c
index 84fe4449..7e9db26f 100644
--- a/xen/block.c
+++ b/xen/block.c
@@ -349,7 +349,7 @@ device_close(void *devp)
 
 static io_return_t
 device_open (ipc_port_t reply_port, mach_msg_type_name_t reply_port_type,
-           dev_mode_t mode, char *name, device_t *devp /* out */)
+           dev_mode_t mode, const char *name, device_t *devp /* out */)
 {
        int i;
        ipc_port_t port, notify;
@@ -666,7 +666,7 @@ device_write(void *d, ipc_port_t reply_port,
       hyp_grant_takeback(gref[j]);
 
     if (err) {
-      printf("error writing %u bytes at sector %d\n", count, bn);
+      printf("error writing %u bytes at sector %ld\n", count, bn);
       break;
     }
   }
diff --git a/xen/console.c b/xen/console.c
index 4907903e..0bf2f712 100644
--- a/xen/console.c
+++ b/xen/console.c
@@ -35,13 +35,7 @@ static struct xencons_interface *console;
 static int kd_pollc;
 int kb_mode;   /* XXX: actually don't care.  */
 
-#undef hyp_console_write
-void hyp_console_write(const char *str, int len)
-{
-       hyp_console_io (CONSOLEIO_write, len, kvtolin(str));
-}
-
-int hypputc(int c)
+static int hypputc(int c)
 {
        if (!console) {
                char d = c;
@@ -142,7 +136,7 @@ int hypcnwrite(dev_t dev, io_req_t ior)
        return char_write(&hypcn_tty, ior);
 }
 
-void hypcnstart(struct tty *tp)
+static void hypcnstart(struct tty *tp)
 {
        spl_t   o_pri;
        int ch;
@@ -166,7 +160,7 @@ void hypcnstart(struct tty *tp)
        }
 }
 
-void hypcnstop()
+static void hypcnstop(struct tty *t, int n)
 {
 }
 
@@ -235,6 +229,6 @@ int hypcninit(struct consdev *cp)
 #ifdef MACH_PV_PAGETABLES
        pmap_set_page_readwrite(console);
 #endif /* MACH_PV_PAGETABLES */
-       hyp_evt_handler(boot_info.console_evtchn, hypcnintr, 0, SPL6);
+       hyp_evt_handler(boot_info.console_evtchn, 
(interrupt_handler_fn)hypcnintr, 0, SPL6);
        return 0;
 }
diff --git a/xen/console.h b/xen/console.h
index 527f5fbd..4a3c541d 100644
--- a/xen/console.h
+++ b/xen/console.h
@@ -25,7 +25,10 @@
 #include <device/cons.h>
 #include <device/io_req.h>
 
-#define hyp_console_write(str, len)    hyp_console_io (CONSOLEIO_write, (len), 
kvtolin(str))
+static inline void hyp_console_write(const char *str, int len)
+{
+       hyp_console_io (CONSOLEIO_write, len, kvtolin(str));
+}
 
 #define hyp_console_put(str) ({ \
        const char *__str = (void*) (str); \
diff --git a/xen/evt.c b/xen/evt.c
index 0ff5c694..cec78c0d 100644
--- a/xen/evt.c
+++ b/xen/evt.c
@@ -91,7 +91,7 @@ void form_int_mask(void)
 extern void hyp_callback(void);
 extern void hyp_failsafe_callback(void);
 
-void hyp_intrinit() {
+void hyp_intrinit(void) {
        form_int_mask();
        curr_ipl = SPLHI;
        hyp_shared_info.evtchn_mask[0] = int_mask[SPLHI];
@@ -104,7 +104,7 @@ void hyp_intrinit() {
 #endif
 }
 
-void hyp_evt_handler(evtchn_port_t port, void (*handler)(), int unit, spl_t 
spl) {
+void hyp_evt_handler(evtchn_port_t port, interrupt_handler_fn handler, int 
unit, spl_t spl) {
        if (port > NEVNT)
                panic("event channel port %d > %d not supported\n", port, (int) 
NEVNT);
        intpri[port] = spl;
diff --git a/xen/evt.h b/xen/evt.h
index e4dbad1b..a73733e0 100644
--- a/xen/evt.h
+++ b/xen/evt.h
@@ -23,7 +23,7 @@
 
 void hyp_intrinit(void);
 void form_int_mask(void);
-void hyp_evt_handler(evtchn_port_t port, void (*handler)(), int unit, spl_t 
spl);
+void hyp_evt_handler(evtchn_port_t port, interrupt_handler_fn handler, int 
unit, spl_t spl);
 void hyp_c_callback(void *ret_addr, void *regs);
 
 #endif /* XEN_EVT_H */
diff --git a/xen/net.c b/xen/net.c
index bec61661..b72844d5 100644
--- a/xen/net.c
+++ b/xen/net.c
@@ -76,7 +76,7 @@ static struct net_data *vif_data;
 
 struct device_emulation_ops hyp_net_emulation_ops;
 
-int hextoi(char *cp, int *nump)
+static int hextoi(char *cp, int *nump)
 {
        int     number;
        char    *original;
@@ -477,7 +477,7 @@ void hyp_net_init(void) {
                        nd->rx_buf_pfn[i] = atop(addr);
                        if (!nd->rx_copy) {
                                if 
(hyp_do_update_va_mapping(kvtolin(nd->rx_buf[i]), 0, UVMF_INVLPG|UVMF_ALL))
-                                       panic("eth: couldn't clear rx kv buf %d 
at %lx", i, addr);
+                                       panic("eth: couldn't clear rx kv buf %d 
at %llx", i, addr);
                        }
                        /* and enqueue it to backend.  */
                        enqueue_rx_buf(nd, i);
@@ -536,7 +536,7 @@ device_close(void *devp)
 
 static io_return_t
 device_open (ipc_port_t reply_port, mach_msg_type_name_t reply_port_type,
-           dev_mode_t mode, char *name, device_t *devp /* out */)
+           dev_mode_t mode, const char *name, device_t *devp /* out */)
 {
        int i, n;
        ipc_port_t port, notify;
diff --git a/xen/time.c b/xen/time.c
index e8abd56b..21791a59 100644
--- a/xen/time.c
+++ b/xen/time.c
@@ -123,17 +123,17 @@ readtodc(uint64_t *tp)
 }
 
 int
-writetodc()
+writetodc(void)
 {
        /* Not allowed in Xen */
        return(-1);
 }
 
 void
-clkstart()
+clkstart(void)
 {
        evtchn_port_t port = hyp_event_channel_bind_virq(VIRQ_TIMER, 0);
-       hyp_evt_handler(port, hypclock_intr, 0, SPLHI);
+       hyp_evt_handler(port, (interrupt_handler_fn)hypclock_intr, 0, SPLHI);
 
        /* first clock tick */
        clock_interrupt(0, 0, 0, 0);
diff --git a/xen/xen.c b/xen/xen.c
index 28953512..6d424474 100644
--- a/xen/xen.c
+++ b/xen/xen.c
@@ -30,7 +30,7 @@
 #include "xen.h"
 #include "evt.h"
 
-void hyp_debug()
+static void hyp_debug(void)
 {
        panic("debug");
 }
@@ -40,7 +40,7 @@ void hyp_init(void)
         hyp_grant_init(); 
         hyp_store_init(); 
        evtchn_port_t port = hyp_event_channel_bind_virq(VIRQ_DEBUG, 0);
-       hyp_evt_handler(port, hyp_debug, 0, SPL7);
+       hyp_evt_handler(port, (interrupt_handler_fn)hyp_debug, 0, SPL7);
 } 
 
 void hyp_dev_init(void)
@@ -50,17 +50,6 @@ void hyp_dev_init(void)
        hyp_net_init(); 
 }
 
-void _hyp_halt(void)
-{
-       hyp_halt();
-}
-
-void _hyp_todo(unsigned long from)
-{
-       printf("TODO: at %lx\n",from);
-       hyp_halt();
-}
-
 extern int int_mask[];
 void hyp_idle(void)
 {
diff --git a/xen/xen.h b/xen/xen.h
index cbb793e2..3fd4028a 100644
--- a/xen/xen.h
+++ b/xen/xen.h
@@ -26,4 +26,16 @@ void hyp_p2m_init(void);
 
 void hypclock_machine_intr(int old_ipl, void *ret_addr, struct 
i386_interrupt_state *regs, uint64_t delta);
 
+struct failsafe_callback_regs {
+       unsigned int ds;
+       unsigned int es;
+       unsigned int fs;
+       unsigned int gs;
+       unsigned int ip;
+       unsigned int cs_and_mask;
+       unsigned int flags;
+};
+
+void hyp_failsafe_c_callback(struct failsafe_callback_regs *regs);
+
 #endif /* XEN_XEN_H */
-- 
2.39.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]