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

[xen stable-4.12] tools/libxc: misc: Mark const the parameter 'keys' of xc_send_debug_keys()

commit b100d3e9acef5b0259b1826c310e90801cf29c01
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Mon Mar 30 20:21:52 2020 +0100
Commit:     Ian Jackson <iwj@xxxxxxxxxxxxxx>
CommitDate: Fri Mar 19 13:46:44 2021 +0000

    tools/libxc: misc: Mark const the parameter 'keys' of xc_send_debug_keys()
    OCaml is using a string to describe the parameter 'keys' of
    xc_send_debug_keys(). Since Ocaml 4.06.01, String_val() will return a
    const char * when using -safe-string. This will result to a build
    failure because xc_send_debug_keys() expects a char *.
    The function should never modify the parameter 'keys' and therefore the
    parameter should be const. Unfortunately, this is not directly possible
    because DECLARE_HYPERCALL_BOUNCE() is expecting a non-const variable.
    A new macro DECLARE_HYPERCALL_BOUNCE_IN() is introduced and will take
    care of const parameter. The first user will be xc_send_debug_keys() but
    this can be used in more place in the future.
    Reported-by: Dario Faggioli <dfaggioli@xxxxxxxx>
    Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
    Reviewed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
    (cherry picked from commit 2b8079610ec55413613ad071cc81cd9f97232a7e)
 tools/libxc/include/xenctrl.h | 2 +-
 tools/libxc/xc_misc.c         | 4 ++--
 tools/libxc/xc_private.h      | 8 ++++++++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 31cdda76c6..833e12d5a1 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1226,7 +1226,7 @@ int xc_readconsolering(xc_interface *xch,
                        unsigned int *pnr_chars,
                        int clear, int incremental, uint32_t *pindex);
-int xc_send_debug_keys(xc_interface *xch, char *keys);
+int xc_send_debug_keys(xc_interface *xch, const char *keys);
 int xc_set_parameters(xc_interface *xch, char *params);
 typedef struct xen_sysctl_physinfo xc_physinfo_t;
diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index 5e6714ae2b..8f2a2dee36 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -167,11 +167,11 @@ int xc_readconsolering(xc_interface *xch,
     return ret;
-int xc_send_debug_keys(xc_interface *xch, char *keys)
+int xc_send_debug_keys(xc_interface *xch, const char *keys)
     int ret, len = strlen(keys);
     if ( xc_hypercall_bounce_pre(xch, keys) )
         return -1;
diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h
index adc3b6a571..c77edb3c4c 100644
--- a/tools/libxc/xc_private.h
+++ b/tools/libxc/xc_private.h
@@ -181,6 +181,14 @@ enum {
 #define DECLARE_HYPERCALL_BOUNCE(_ubuf, _sz, _dir) 
DECLARE_NAMED_HYPERCALL_BOUNCE(_ubuf, _ubuf, _sz, _dir)
+ * Declare a bounce buffer shadowing the named user data pointer that
+ * cannot be modified.
+ */
+#define DECLARE_HYPERCALL_BOUNCE_IN(_ubuf, _sz)                     \
+    DECLARE_NAMED_HYPERCALL_BOUNCE(_ubuf, (void *)(_ubuf), _sz,     \
+                                   XC_HYPERCALL_BUFFER_BOUNCE_IN)
  * Set the size of data to bounce. Useful when the size is not known
  * when the bounce buffer is declared.
generated by git-patchbot for /home/xen/git/xen.git#stable-4.12



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.