From 5383ddccb02faa9136b7952293945249c768f2e5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 3 Apr 2021 05:55:52 +0300 Subject: [PATCH 38/44] Fix Qt-client shadow warning about 'password' Rename global variable 'password' as 'fc_password' to avoid conflict with Qt headers. See osdn #41905 Signed-off-by: Marko Lindqvist --- client/client_main.c | 2 +- client/client_main.h | 2 +- client/gui-gtk-3.22/pages.c | 14 +++++++------- client/gui-gtk-4.0/pages.c | 14 +++++++------- client/gui-qt/pages.cpp | 12 ++++++------ client/gui-sdl2/connectdlg.c | 26 +++++++++++++------------- client/gui-stub/connectdlg.c | 6 +++--- client/options.c | 2 +- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/client/client_main.c b/client/client_main.c index bd97d03fdf..8dd7a02464 100644 --- a/client/client_main.c +++ b/client/client_main.c @@ -139,7 +139,7 @@ char sound_set_name[512] = "\0"; char music_set_name[512] = "\0"; char server_host[512] = "\0"; char user_name[512] = "\0"; -char password[MAX_LEN_PASSWORD] = "\0"; +char fc_password[MAX_LEN_PASSWORD] = "\0"; char metaserver[512] = "\0"; int server_port = -1; bool auto_connect = FALSE; /* TRUE = skip "Connect to Freeciv Server" dialog */ diff --git a/client/client_main.h b/client/client_main.h index d6e7a04395..6f98d06ef8 100644 --- a/client/client_main.h +++ b/client/client_main.h @@ -74,7 +74,7 @@ extern char sound_set_name[512]; extern char music_set_name[512]; extern char server_host[512]; extern char user_name[512]; -extern char password[MAX_LEN_PASSWORD]; +extern char fc_password[MAX_LEN_PASSWORD]; extern char metaserver[512]; extern int server_port; extern bool auto_connect; diff --git a/client/gui-gtk-3.22/pages.c b/client/gui-gtk-3.22/pages.c index 1c4de9eda6..2085dfb18b 100644 --- a/client/gui-gtk-3.22/pages.c +++ b/client/gui-gtk-3.22/pages.c @@ -996,12 +996,12 @@ void handle_authentication_req(enum authentication_type type, set_connection_state(NEW_PASSWORD_TYPE); return; case AUTH_LOGIN_FIRST: - /* if we magically have a password already present in 'password' + /* if we magically have a password already present in 'fc_password' * then, use that and skip the password entry dialog */ - if (password[0] != '\0') { + if (fc_password[0] != '\0') { struct packet_authentication_reply reply; - sz_strlcpy(reply.password, password); + sz_strlcpy(reply.password, fc_password); send_packet_authentication_reply(&client.conn, &reply); return; } else { @@ -1042,18 +1042,18 @@ static void connect_callback(GtkWidget *w, gpointer data) return; case NEW_PASSWORD_TYPE: if (w != network_password) { - sz_strlcpy(password, + sz_strlcpy(fc_password, gtk_entry_get_text(GTK_ENTRY(network_password))); sz_strlcpy(reply.password, gtk_entry_get_text(GTK_ENTRY(network_confirm_password))); - if (strncmp(reply.password, password, MAX_LEN_NAME) == 0) { - password[0] = '\0'; + if (strncmp(reply.password, fc_password, MAX_LEN_NAME) == 0) { + fc_password[0] = '\0'; send_packet_authentication_reply(&client.conn, &reply); set_connection_state(WAITING_TYPE); } else { append_network_statusbar(_("Passwords don't match, enter password."), - TRUE); + TRUE); set_connection_state(NEW_PASSWORD_TYPE); } diff --git a/client/gui-gtk-4.0/pages.c b/client/gui-gtk-4.0/pages.c index 9f4923b0b3..6114de33a9 100644 --- a/client/gui-gtk-4.0/pages.c +++ b/client/gui-gtk-4.0/pages.c @@ -999,12 +999,12 @@ void handle_authentication_req(enum authentication_type type, set_connection_state(NEW_PASSWORD_TYPE); return; case AUTH_LOGIN_FIRST: - /* if we magically have a password already present in 'password' + /* if we magically have a password already present in 'fc_password' * then, use that and skip the password entry dialog */ - if (password[0] != '\0') { + if (fc_password[0] != '\0') { struct packet_authentication_reply reply; - sz_strlcpy(reply.password, password); + sz_strlcpy(reply.password, fc_password); send_packet_authentication_reply(&client.conn, &reply); return; } else { @@ -1047,18 +1047,18 @@ static void connect_callback(GtkWidget *w, gpointer data) return; case NEW_PASSWORD_TYPE: if (w != network_password) { - sz_strlcpy(password, + sz_strlcpy(fc_password, gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(network_password)))); sz_strlcpy(reply.password, gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(network_confirm_password)))); - if (strncmp(reply.password, password, MAX_LEN_NAME) == 0) { - password[0] = '\0'; + if (strncmp(reply.password, fc_password, MAX_LEN_NAME) == 0) { + fc_password[0] = '\0'; send_packet_authentication_reply(&client.conn, &reply); set_connection_state(WAITING_TYPE); } else { append_network_statusbar(_("Passwords don't match, enter password."), - TRUE); + TRUE); set_connection_state(NEW_PASSWORD_TYPE); } diff --git a/client/gui-qt/pages.cpp b/client/gui-qt/pages.cpp index cce4e6a494..682a06cf4b 100644 --- a/client/gui-qt/pages.cpp +++ b/client/gui-qt/pages.cpp @@ -1544,12 +1544,12 @@ void fc_client::handle_authentication_req(enum authentication_type type, set_connection_state(NEW_PASSWORD_TYPE); return; case AUTH_LOGIN_FIRST: - /* if we magically have a password already present in 'password' + /* if we magically have a password already present in 'fc_password' * then, use that and skip the password entry dialog */ - if (password[0] != '\0') { + if (fc_password[0] != '\0') { struct packet_authentication_reply reply; - sz_strlcpy(reply.password, password); + sz_strlcpy(reply.password, fc_password); send_packet_authentication_reply(&client.conn, &reply); return; } else { @@ -1594,13 +1594,13 @@ void fc_client::slot_connect() return; case NEW_PASSWORD_TYPE: ba_bytes = connect_password_edit->text().toLatin1(); - sz_strlcpy(password, ba_bytes.data()); + sz_strlcpy(fc_password, ba_bytes.data()); ba_bytes = connect_confirm_password_edit->text().toLatin1(); sz_strlcpy(reply.password, ba_bytes.data()); - if (strncmp(reply.password, password, MAX_LEN_NAME) == 0) { - password[0] = '\0'; + if (strncmp(reply.password, fc_password, MAX_LEN_NAME) == 0) { + fc_password[0] = '\0'; send_packet_authentication_reply(&client.conn, &reply); set_connection_state(WAITING_TYPE); } else { diff --git a/client/gui-sdl2/connectdlg.c b/client/gui-sdl2/connectdlg.c index 22f242dcab..5118c29fda 100644 --- a/client/gui-sdl2/connectdlg.c +++ b/client/gui-sdl2/connectdlg.c @@ -724,7 +724,7 @@ static int convert_passwd_callback(struct widget *pwidget) { if (PRESSED_EVENT(main_data.event)) { if (pwidget->string_utf8->text != NULL) { - fc_snprintf(password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text); + fc_snprintf(fc_password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text); } } @@ -739,10 +739,10 @@ static int send_passwd_callback(struct widget *pwidget) if (PRESSED_EVENT(main_data.event)) { struct packet_authentication_reply reply; - sz_strlcpy(reply.password, password); + sz_strlcpy(reply.password, fc_password); - memset(password, 0, MAX_LEN_NAME); - password[0] = '\0'; + memset(fc_password, 0, MAX_LEN_NAME); + fc_password[0] = '\0'; set_wstate(pwidget, FC_WS_DISABLED); @@ -763,8 +763,8 @@ static int send_passwd_callback(struct widget *pwidget) **************************************************************************/ static int cancel_passwd_callback(struct widget *pwidget) { - memset(password, 0, MAX_LEN_NAME); - password[0] = '\0'; + memset(fc_password, 0, MAX_LEN_NAME); + fc_password[0] = '\0'; disconnect_from_server(); return cancel_connect_dlg_callback(pwidget); @@ -899,7 +899,7 @@ static int convert_first_passwd_callback(struct widget *pwidget) { if (PRESSED_EVENT(main_data.event)) { if (pwidget->string_utf8->text != NULL) { - fc_snprintf(password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text); + fc_snprintf(fc_password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text); set_wstate(pwidget->prev, FC_WS_NORMAL); widget_redraw(pwidget->prev); widget_flush(pwidget->prev); @@ -916,13 +916,13 @@ static int convert_second_passwd_callback(struct widget *pwidget) { if (PRESSED_EVENT(main_data.event)) { if (pwidget->string_utf8->text != NULL - && !strncmp(password, pwidget->string_utf8->text, MAX_LEN_NAME)) { + && !strncmp(fc_password, pwidget->string_utf8->text, MAX_LEN_NAME)) { set_wstate(pwidget->prev, FC_WS_NORMAL); /* next button */ widget_redraw(pwidget->prev); widget_flush(pwidget->prev); } else { - memset(password, 0, MAX_LEN_NAME); - password[0] = '\0'; + memset(fc_password, 0, MAX_LEN_NAME); + fc_password[0] = '\0'; FC_FREE(pwidget->next->string_utf8->text);/* first edit */ FC_FREE(pwidget->string_utf8->text); /* second edit */ @@ -1109,12 +1109,12 @@ void handle_authentication_req(enum authentication_type type, popup_new_user_passwd_dialog(message); return; case AUTH_LOGIN_FIRST: - /* if we magically have a password already present in 'password' + /* if we magically have a password already present in 'fc_password' * then, use that and skip the password entry dialog */ - if (password[0] != '\0') { + if (fc_password[0] != '\0') { struct packet_authentication_reply reply; - sz_strlcpy(reply.password, password); + sz_strlcpy(reply.password, fc_password); send_packet_authentication_reply(&client.conn, &reply); return; diff --git a/client/gui-stub/connectdlg.c b/client/gui-stub/connectdlg.c index 14a65cbf97..71c4596bfe 100644 --- a/client/gui-stub/connectdlg.c +++ b/client/gui-stub/connectdlg.c @@ -58,12 +58,12 @@ void handle_authentication_req(enum authentication_type type, /* PORTME: switch configs if need be */ return; case AUTH_LOGIN_FIRST: - /* if we magically have a password already present in 'password' + /* if we magically have a password already present in 'fc_password' * then, use that and skip the password entry dialog */ - if (password[0] != '\0') { + if (fc_password[0] != '\0') { struct packet_authentication_reply reply; - sz_strlcpy(reply.password, password); + sz_strlcpy(reply.password, fc_password); send_packet_authentication_reply(&client.conn, &reply); return; } else { diff --git a/client/options.c b/client/options.c index 619c420d1a..be232ef384 100644 --- a/client/options.c +++ b/client/options.c @@ -5755,7 +5755,7 @@ void options_load(void) secfile_allow_digital_boolean(sf, allow_digital_boolean); /* a "secret" option for the lazy. TODO: make this saveable */ - sz_strlcpy(password, + sz_strlcpy(fc_password, secfile_lookup_str_default(sf, "", "%s.password", prefix)); gui_options.save_options_on_exit = -- 2.30.2