[gtk-vnc] Fix compiler warning in gvnccapture.c
- From: Daniel P. Berrange <dberrange src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-vnc] Fix compiler warning in gvnccapture.c
- Date: Fri, 9 Dec 2011 17:41:34 +0000 (UTC)
commit 925eb993ea021cc5d54b750b1194ebe31eec82e0
Author: Daniel P. Berrange <berrange redhat com>
Date: Fri Dec 9 15:50:50 2011 +0000
Fix compiler warning in gvnccapture.c
Recent GCC warn about assignments to variables which are then
not used.
tools/gvnccapture.c | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/tools/gvnccapture.c b/tools/gvnccapture.c
index da94173..baa6613 100644
--- a/tools/gvnccapture.c
+++ b/tools/gvnccapture.c
@@ -135,12 +135,11 @@ static const guint preferable_auths[] = {
};
+#ifdef HAVE_TERMIOS_H
static gchar *
do_vnc_get_credential(const gchar *prompt, gboolean doecho)
{
-#ifdef HAVE_TERMIOS_H
struct termios old, new;
-#endif
gchar buf[100];
gchar *res;
int n = sizeof(buf);
@@ -149,7 +148,6 @@ do_vnc_get_credential(const gchar *prompt, gboolean doecho)
printf("%s", prompt);
fflush(stdout);
-#ifdef HAVE_TERMIOS_H
/* Turn echoing off and fail if we can't. */
if (!doecho && tcgetattr (fileno (stdin), &old) != 0)
return NULL;
@@ -157,9 +155,6 @@ do_vnc_get_credential(const gchar *prompt, gboolean doecho)
new.c_lflag &= ~ECHO;
if (!doecho && tcsetattr(fileno(stdin), TCSAFLUSH, &new) != 0)
return NULL;
-#else
- doecho = TRUE; /* Avoid unused parameter compile warning */
-#endif
/* Read the password. */
if ((res = fgets(buf, n, stdin)) != NULL) {
@@ -168,17 +163,36 @@ do_vnc_get_credential(const gchar *prompt, gboolean doecho)
res[len-1] = '\0';
}
-#ifdef HAVE_TERMIOS_H
/* Restore terminal. */
if (!doecho) {
printf("\n");
(void) tcsetattr(fileno (stdin), TCSAFLUSH, &old);
}
-#endif
return res ? g_strdup(res) : NULL;
}
+#else
+static gchar *
+do_vnc_get_credential(const gchar *prompt, gboolean doecho G_GNUC_UNUSED)
+{
+ gchar buf[100];
+ gchar *res;
+ int n = sizeof(buf);
+ ssize_t len;
+
+ printf("%s", prompt);
+ fflush(stdout);
+
+ /* Read the password. */
+ if ((res = fgets(buf, n, stdin)) != NULL) {
+ len = strlen(res);
+ if (res[len-1] == '\n')
+ res[len-1] = '\0';
+ }
+ return res ? g_strdup(res) : NULL;
+}
+#endif
static void do_vnc_framebuffer_update(VncConnection *conn,
guint16 x, guint16 y,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]