From d57989cbeb25f35800c2780c78f0c9f459bd71e1 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 3 Apr 2021 06:38:58 +0300 Subject: [PATCH 27/29] 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-2.0/pages.c | 14 +++++------ client/gui-gtk-3.0/pages.c | 14 +++++------ client/gui-gtk-3.22/pages.c | 14 +++++------ client/gui-qt/pages.cpp | 12 ++++----- client/gui-sdl/connectdlg.c | 48 +++++++++++++++++++----------------- client/gui-sdl2/connectdlg.c | 26 +++++++++---------- client/gui-stub/connectdlg.c | 6 ++--- client/gui-xaw/connectdlg.c | 12 ++++----- client/options.c | 2 +- 11 files changed, 77 insertions(+), 75 deletions(-) diff --git a/client/client_main.c b/client/client_main.c index 0adf2b6a9e..4a9d3e9371 100644 --- a/client/client_main.c +++ b/client/client_main.c @@ -138,7 +138,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 efc79559a4..f33cdb8dc3 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-2.0/pages.c b/client/gui-gtk-2.0/pages.c index e6cf7780eb..e0fd0f5784 100644 --- a/client/gui-gtk-2.0/pages.c +++ b/client/gui-gtk-2.0/pages.c @@ -913,12 +913,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 { @@ -959,18 +959,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-3.0/pages.c b/client/gui-gtk-3.0/pages.c index 7555815a96..d46daaf35f 100644 --- a/client/gui-gtk-3.0/pages.c +++ b/client/gui-gtk-3.0/pages.c @@ -995,12 +995,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 { @@ -1041,18 +1041,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-3.22/pages.c b/client/gui-gtk-3.22/pages.c index fd015db6a0..ac43e32de0 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-qt/pages.cpp b/client/gui-qt/pages.cpp index a816580088..b4283bdec5 100644 --- a/client/gui-qt/pages.cpp +++ b/client/gui-qt/pages.cpp @@ -1526,12 +1526,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 { @@ -1576,13 +1576,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-sdl/connectdlg.c b/client/gui-sdl/connectdlg.c index 15ac7a9382..28a8cf5330 100644 --- a/client/gui-sdl/connectdlg.c +++ b/client/gui-sdl/connectdlg.c @@ -732,8 +732,9 @@ static int convert_passwd_callback(struct widget *pWidget) { if (Main.event.button.button == SDL_BUTTON_LEFT) { char *tmp = convert_to_chars(pWidget->string16->text); - if(tmp) { - fc_snprintf(password, MAX_LEN_NAME, "%s", tmp); + + if (tmp) { + fc_snprintf(fc_password, MAX_LEN_NAME, "%s", tmp); FC_FREE(tmp); } } @@ -747,12 +748,12 @@ static int send_passwd_callback(struct widget *pWidget) { if (Main.event.button.button == SDL_BUTTON_LEFT) { struct packet_authentication_reply reply; - - sz_strlcpy(reply.password, password); - - memset(password, 0, MAX_LEN_NAME); - password[0] = '\0'; - + + sz_strlcpy(reply.password, fc_password); + + memset(fc_password, 0, MAX_LEN_NAME); + fc_password[0] = '\0'; + set_wstate(pWidget, FC_WS_DISABLED); widget_redraw(pWidget); @@ -771,9 +772,10 @@ 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); } @@ -906,9 +908,9 @@ static int convert_first_passwd_callback(struct widget *pWidget) { if (Main.event.button.button == SDL_BUTTON_LEFT) { char *tmp = convert_to_chars(pWidget->string16->text); - - if(tmp) { - fc_snprintf(password, MAX_LEN_NAME, "%s", tmp); + + if (tmp) { + fc_snprintf(fc_password, MAX_LEN_NAME, "%s", tmp); FC_FREE(tmp); set_wstate(pWidget->prev, FC_WS_NORMAL); widget_redraw(pWidget->prev); @@ -925,17 +927,17 @@ static int convert_secound_passwd_callback(struct widget *pWidget) { if (Main.event.button.button == SDL_BUTTON_LEFT) { char *tmp = convert_to_chars(pWidget->string16->text); - - if (tmp && strncmp(password, tmp, MAX_LEN_NAME) == 0) { + + if (tmp && strncmp(fc_password, tmp, MAX_LEN_NAME) == 0) { 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'; - - FC_FREE(pWidget->next->string16->text);/* first edit */ - FC_FREE(pWidget->string16->text); /* secound edit */ + memset(fc_password, 0, MAX_LEN_NAME); + fc_password[0] = '\0'; + + FC_FREE(pWidget->next->string16->text); /* first edit */ + FC_FREE(pWidget->string16->text); /* second edit */ popup_new_user_passwd_dialog(_("Passwords don't match, enter password.")); } @@ -1115,12 +1117,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; } else { diff --git a/client/gui-sdl2/connectdlg.c b/client/gui-sdl2/connectdlg.c index c252aae27e..b2a330aa86 100644 --- a/client/gui-sdl2/connectdlg.c +++ b/client/gui-sdl2/connectdlg.c @@ -729,7 +729,7 @@ static int convert_passwd_callback(struct widget *pWidget) { if (PRESSED_EVENT(Main.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); } } @@ -744,10 +744,10 @@ static int send_passwd_callback(struct widget *pWidget) if (PRESSED_EVENT(Main.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); @@ -768,8 +768,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); @@ -903,7 +903,7 @@ static int convert_first_passwd_callback(struct widget *pWidget) { if (PRESSED_EVENT(Main.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); @@ -920,13 +920,13 @@ static int convert_second_passwd_callback(struct widget *pWidget) { if (PRESSED_EVENT(Main.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 */ @@ -1111,12 +1111,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 6b2ae10126..9ac4d27f33 100644 --- a/client/gui-stub/connectdlg.c +++ b/client/gui-stub/connectdlg.c @@ -65,12 +65,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/gui-xaw/connectdlg.c b/client/gui-xaw/connectdlg.c index d5139ac140..aa2c9000f0 100644 --- a/client/gui-xaw/connectdlg.c +++ b/client/gui-xaw/connectdlg.c @@ -428,11 +428,11 @@ void connectdlg_connect_callback(Widget w, XtPointer client_data, break; case NEW_PASSWORD_TYPE: XtVaGetValues(connectdlg_password_text, XtNstring, &pxp, NULL); - sz_strlcpy(password, (char *)pxp); + sz_strlcpy(fc_password, (char *)pxp); XtVaGetValues(connectdlg_verify_text, XtNstring, &pxp, NULL); sz_strlcpy(reply.password, (char *)pxp); - 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); XtVaSetValues(connectdlg_message_label, XtNlabel, "", NULL); XtVaSetValues(connectdlg_password_text, XtNsensitive, False, NULL); @@ -513,12 +513,12 @@ void handle_authentication_req(enum authentication_type type, connection_status = NEW_PASSWORD_TYPE; break; 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 820839ba3f..6825846dd5 100644 --- a/client/options.c +++ b/client/options.c @@ -5766,7 +5766,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