[PATCH v2] build: silence a clang warning in virsh.c

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

 



This patch shuts up the following warning of clang
on Mac OS X:

  virsh.c:2761:22: error: assigning to 'char *' from 'const char [6]' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      rl_readline_name = "virsh";
                       ^ ~~~~~~~

The warning happens because rl_readline_name on Mac OS X is still
'char *', while it is 'const char *' on most platforms. So adding
a cast to (char *) can suppress the warning, although that is not
necessary for other platforms.

Tested on Mac OS X 10.8.5 (clang-500.2.75) and Fedora 19 (gcc 4.8.1).

Signed-off-by: Ryota Ozaki <ozaki.ryota@xxxxxxxxx>
---
 tools/virsh.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 241c5b8..1edffb3 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2757,8 +2757,12 @@ vshReadlineInit(vshControl *ctl)
     int max_history = 500;
     const char *histsize_str;
 
-    /* Allow conditional parsing of the ~/.inputrc file. */
-    rl_readline_name = "virsh";
+    /* Allow conditional parsing of the ~/.inputrc file.
+     * XXX: the cast is necessary for Mac OS X to slient
+     * clang's warning. On Mac OS X, rl_readline_name is
+     * char * while on most platforms it's const char *.
+     */
+    rl_readline_name = (char *) "virsh";
 
     /* Tell the completer that we want a crack first. */
     rl_attempted_completion_function = vshReadlineCompletion;
-- 
1.8.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]