Skip to contentSkip to conversation

tools: xl: more const-correctness

PATCH In review Ian Jackson 1 participant 2 messages Nov 8, 2010 – Nov 9, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: xl: more const-correctness

# HG changeset patch
# User Ian Jackson <[email protected]> # Date 1289235914 0
# Node ID 711cb42299000e7376ed1a8d987cd81da5f31238 # Parent 2c32482d8c90eb2b51c708fd770e19bbdfb5d2b6
tools: xl: more const-correctness

The implementation of xl was lacking a lot of consts on its char*s. In this patch we improve matters. It doesn't fix everything. In particular:

* I only changed char*s and not other structs that ought to be const.

* libxl_send_debug_keys should take a const char* but the pointer ends up getting sent to DECLARE_HYPERCALL_BOUNCE from xc_private.h and that won't take a const char*. I wasn't sure what to do so I have left it.

* There is a great deal of in-place string tokenisation (both ad-hoc, and using strtok_r). I haven't changed any of that.

* I haven't changed any of the occurrences of char **argv because of the castless assignment incompatibility between const char** and char **.

tools/libxl/xl.h +1 -1
diff -r 2c32482d8c90 -r 711cb4229900 tools/libxl/xl.h
@@ -86,7 +86,7 @@ int main_cpupoolcpuremove(int argc, char
 int main_cpupoolcpuremove(int argc, char **argv);
 int main_cpupoolmigrate(int argc, char **argv);
 
-void help(char *command);
+void help(const char *command);
 
 extern struct cmd_spec cmd_table[];
 extern int cmdtable_len;
tools/libxl/xl_cmdimpl.c +81 -74

526 lines not on this page · raw message

#1 lore raw
Quoted 1 line · I wrote:

tools: xl: more const-correctness

Looks like I was a bit over-enthusiastic:

# HG changeset patch
# User Ian Jackson <[email protected]>
# Date 1289304005 0
# Node ID 7188d1e4b0e1ce409912dfa6d17f853720959053
# Parent cf7a126298fb8d16c564592bb95d18b7dca0a633
tools: libxl: Fix some "const const"s introduced in 711cb4229900

tools/libxl/xl_cmdimpl.c +2 -2
diff -r cf7a126298fb -r 7188d1e4b0e1 tools/libxl/xl_cmdimpl.c
@@ -2161,7 +2161,7 @@ int main_console(int argc, char **argv)
     return 1;
 }
 
-static int vncviewer(const const char *domain_spec, int autopass)
+static int vncviewer(const char *domain_spec, int autopass)
 {
     find_domain(domain_spec);
     libxl_vncviewer_exec(&ctx, domid, autopass);
@@ -5323,7 +5323,7 @@ int main_tmem_freeable(int argc, char **
 
 int main_cpupoolcreate(int argc, char **argv)
 {
-    const const char *filename = NULL;
+    const char *filename = NULL;
     const char *p;
     char extra_config[1024];
     int dryrun = 0;