vnc: introduce a single label for error returns
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
		
							parent
							
								
									c1c1619c8b
								
							
						
					
					
						commit
						1ce52c78ab
					
				
							
								
								
									
										42
									
								
								ui/vnc.c
								
								
								
								
							
							
						
						
									
										42
									
								
								ui/vnc.c
								
								
								
								
							| 
						 | 
					@ -2874,8 +2874,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
 | 
				
			||||||
    if (strcmp(display, "none") == 0)
 | 
					    if (strcmp(display, "none") == 0)
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!(vs->display = strdup(display)))
 | 
					    vs->display = g_strdup(display);
 | 
				
			||||||
        return -1;
 | 
					 | 
				
			||||||
    vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
 | 
					    vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    options = display;
 | 
					    options = display;
 | 
				
			||||||
| 
						 | 
					@ -2887,9 +2886,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
 | 
				
			||||||
                        "VNC password auth disabled due to FIPS mode, "
 | 
					                        "VNC password auth disabled due to FIPS mode, "
 | 
				
			||||||
                        "consider using the VeNCrypt or SASL authentication "
 | 
					                        "consider using the VeNCrypt or SASL authentication "
 | 
				
			||||||
                        "methods as an alternative\n");
 | 
					                        "methods as an alternative\n");
 | 
				
			||||||
                g_free(vs->display);
 | 
					                goto fail;
 | 
				
			||||||
                vs->display = NULL;
 | 
					 | 
				
			||||||
                return -1;
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            password = 1; /* Require password auth */
 | 
					            password = 1; /* Require password auth */
 | 
				
			||||||
        } else if (strncmp(options, "reverse", 7) == 0) {
 | 
					        } else if (strncmp(options, "reverse", 7) == 0) {
 | 
				
			||||||
| 
						 | 
					@ -2921,16 +2918,12 @@ int vnc_display_open(DisplayState *ds, const char *display)
 | 
				
			||||||
                if (vnc_tls_set_x509_creds_dir(vs, path) < 0) {
 | 
					                if (vnc_tls_set_x509_creds_dir(vs, path) < 0) {
 | 
				
			||||||
                    fprintf(stderr, "Failed to find x509 certificates/keys in %s\n", path);
 | 
					                    fprintf(stderr, "Failed to find x509 certificates/keys in %s\n", path);
 | 
				
			||||||
                    g_free(path);
 | 
					                    g_free(path);
 | 
				
			||||||
                    g_free(vs->display);
 | 
					                    goto fail;
 | 
				
			||||||
                    vs->display = NULL;
 | 
					 | 
				
			||||||
                    return -1;
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                g_free(path);
 | 
					                g_free(path);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                fprintf(stderr, "No certificate path provided\n");
 | 
					                fprintf(stderr, "No certificate path provided\n");
 | 
				
			||||||
                g_free(vs->display);
 | 
					                goto fail;
 | 
				
			||||||
                vs->display = NULL;
 | 
					 | 
				
			||||||
                return -1;
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL)
 | 
					#if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL)
 | 
				
			||||||
| 
						 | 
					@ -2950,9 +2943,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
 | 
				
			||||||
                vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED;
 | 
					                vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                fprintf(stderr, "unknown vnc share= option\n");
 | 
					                fprintf(stderr, "unknown vnc share= option\n");
 | 
				
			||||||
                g_free(vs->display);
 | 
					                goto fail;
 | 
				
			||||||
                vs->display = NULL;
 | 
					 | 
				
			||||||
                return -1;
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -3055,9 +3046,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
 | 
				
			||||||
    if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) {
 | 
					    if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) {
 | 
				
			||||||
        fprintf(stderr, "Failed to initialize SASL auth %s",
 | 
					        fprintf(stderr, "Failed to initialize SASL auth %s",
 | 
				
			||||||
                sasl_errstring(saslErr, NULL, NULL));
 | 
					                sasl_errstring(saslErr, NULL, NULL));
 | 
				
			||||||
        g_free(vs->display);
 | 
					        goto fail;
 | 
				
			||||||
        vs->display = NULL;
 | 
					 | 
				
			||||||
        return -1;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    vs->lock_key_sync = lock_key_sync;
 | 
					    vs->lock_key_sync = lock_key_sync;
 | 
				
			||||||
| 
						 | 
					@ -3069,9 +3058,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            vs->lsock = inet_connect(display, NULL);
 | 
					            vs->lsock = inet_connect(display, NULL);
 | 
				
			||||||
        if (vs->lsock < 0) {
 | 
					        if (vs->lsock < 0) {
 | 
				
			||||||
            g_free(vs->display);
 | 
					            goto fail;
 | 
				
			||||||
            vs->display = NULL;
 | 
					 | 
				
			||||||
            return -1;
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            int csock = vs->lsock;
 | 
					            int csock = vs->lsock;
 | 
				
			||||||
            vs->lsock = -1;
 | 
					            vs->lsock = -1;
 | 
				
			||||||
| 
						 | 
					@ -3092,13 +3079,18 @@ int vnc_display_open(DisplayState *ds, const char *display)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (vs->lsock < 0) {
 | 
					        if (vs->lsock < 0) {
 | 
				
			||||||
            g_free(dpy);
 | 
					            g_free(dpy);
 | 
				
			||||||
            return -1;
 | 
					            goto fail;
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            g_free(vs->display);
 | 
					 | 
				
			||||||
            vs->display = dpy;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        g_free(vs->display);
 | 
				
			||||||
 | 
					        vs->display = dpy;
 | 
				
			||||||
 | 
					        qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_read, NULL, vs);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_read, NULL, vs);
 | 
					    return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fail:
 | 
				
			||||||
 | 
					    g_free(vs->display);
 | 
				
			||||||
 | 
					    vs->display = NULL;
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void vnc_display_add_client(DisplayState *ds, int csock, int skipauth)
 | 
					void vnc_display_add_client(DisplayState *ds, int csock, int skipauth)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue