Minor cleanup of askpass code.
This commit is contained in:
		@@ -51,13 +51,13 @@ const char *mpw_askpass(const char *prompt) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    int pipes[2];
 | 
					    int pipes[2];
 | 
				
			||||||
    if (pipe( pipes ) == ERR) {
 | 
					    if (pipe( pipes ) == ERR) {
 | 
				
			||||||
        wrn( "Couldn't pipe: %s", strerror( errno ) );
 | 
					        wrn( "Couldn't create pipes for askpass: %s", strerror( errno ) );
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pid_t pid = fork();
 | 
					    pid_t pid = fork();
 | 
				
			||||||
    if (pid == ERR) {
 | 
					    if (pid == ERR) {
 | 
				
			||||||
        wrn( "Couldn't fork for askpass:\n  %s: %s", askpass, strerror( errno ) );
 | 
					        wrn( "Couldn't fork for askpass: %s", askpass, strerror( errno ) );
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -83,15 +83,16 @@ const char *mpw_askpass(const char *prompt) {
 | 
				
			|||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (WIFEXITED( status ) && WEXITSTATUS( status ) == EXIT_SUCCESS && answer && strlen( answer )) {
 | 
					    if (!WIFEXITED( status ) || WEXITSTATUS( status ) != EXIT_SUCCESS || !answer || !strlen( answer )) {
 | 
				
			||||||
        // Remove trailing newline.
 | 
					        // askpass failed.
 | 
				
			||||||
        if (answer[strlen( answer ) - 1] == '\n')
 | 
					        mpw_free_string( &answer );
 | 
				
			||||||
            mpw_replace_string( answer, mpw_strndup( answer, strlen( answer ) - 1 ) );
 | 
					        return NULL;
 | 
				
			||||||
        return answer;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mpw_free_string( &answer );
 | 
					    // Remove trailing newline.
 | 
				
			||||||
    return NULL;
 | 
					    if (answer[strlen( answer ) - 1] == '\n')
 | 
				
			||||||
 | 
					        mpw_replace_string( answer, mpw_strndup( answer, strlen( answer ) - 1 ) );
 | 
				
			||||||
 | 
					    return answer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char *_mpw_getline(const char *prompt, bool silent) {
 | 
					static const char *_mpw_getline(const char *prompt, bool silent) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user