client-conf: Don't report failure from pa_client_conf_load()

pa_context already ignored the return value of pa_client_conf_load(),
so the only places where the return value was not ignored were the
D-Bus server lookup thing and pax11publish. I don't think those cases
are negatively affected if they ignore errors in opening or parsing
client.conf.

pa_client_conf_env() never failed anyway, so returning int was
obviously redundant.
This commit is contained in:
Tanu Kaskinen 2014-06-08 16:32:53 +03:00
parent d02511115c
commit 067e61cb66
4 changed files with 12 additions and 56 deletions

View file

@ -115,7 +115,6 @@ finish:
enum get_address_result_t { enum get_address_result_t {
SUCCESS, SUCCESS,
FAILED_TO_LOAD_CLIENT_CONF,
SERVER_FROM_TYPE_FAILED SERVER_FROM_TYPE_FAILED
}; };
@ -126,10 +125,7 @@ static enum get_address_result_t get_address(pa_server_type_t server_type, char
*address = NULL; *address = NULL;
if (pa_client_conf_load(conf) < 0) { pa_client_conf_load(conf);
r = FAILED_TO_LOAD_CLIENT_CONF;
goto finish;
}
if (conf->default_dbus_server) if (conf->default_dbus_server)
*address = pa_xstrdup(conf->default_dbus_server); *address = pa_xstrdup(conf->default_dbus_server);
@ -180,18 +176,6 @@ static DBusHandlerResult handle_get_address(DBusConnection *conn, DBusMessage *m
r = DBUS_HANDLER_RESULT_HANDLED; r = DBUS_HANDLER_RESULT_HANDLED;
goto finish; goto finish;
case FAILED_TO_LOAD_CLIENT_CONF:
if (!(reply = dbus_message_new_error(msg, "org.pulseaudio.ClientConfLoadError", "Failed to load client.conf."))) {
r = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
goto finish;
}
if (!dbus_connection_send(conn, reply, NULL)) {
r = DBUS_HANDLER_RESULT_NEED_MEMORY;
goto finish;
}
r = DBUS_HANDLER_RESULT_HANDLED;
goto finish;
case SERVER_FROM_TYPE_FAILED: case SERVER_FROM_TYPE_FAILED:
if (!(reply = dbus_message_new_error(msg, DBUS_ERROR_FAILED, "PulseAudio internal error: get_dbus_server_from_type() failed."))) { if (!(reply = dbus_message_new_error(msg, DBUS_ERROR_FAILED, "PulseAudio internal error: get_dbus_server_from_type() failed."))) {
r = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; r = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@ -398,18 +382,6 @@ static DBusHandlerResult handle_get_all(DBusConnection *conn, DBusMessage *msg,
r = DBUS_HANDLER_RESULT_HANDLED; r = DBUS_HANDLER_RESULT_HANDLED;
goto finish; goto finish;
case FAILED_TO_LOAD_CLIENT_CONF:
if (!(reply = dbus_message_new_error(msg, "org.pulseaudio.ClientConfLoadError", "Failed to load client.conf."))) {
r = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
goto finish;
}
if (!dbus_connection_send(conn, reply, NULL)) {
r = DBUS_HANDLER_RESULT_NEED_MEMORY;
goto finish;
}
r = DBUS_HANDLER_RESULT_HANDLED;
goto finish;
case SERVER_FROM_TYPE_FAILED: case SERVER_FROM_TYPE_FAILED:
if (!(reply = dbus_message_new_error(msg, DBUS_ERROR_FAILED, "PulseAudio internal error: get_dbus_server_from_type() failed."))) { if (!(reply = dbus_message_new_error(msg, DBUS_ERROR_FAILED, "PulseAudio internal error: get_dbus_server_from_type() failed."))) {
r = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; r = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

View file

@ -91,10 +91,9 @@ void pa_client_conf_free(pa_client_conf *c) {
pa_xfree(c); pa_xfree(c);
} }
int pa_client_conf_load(pa_client_conf *c) { void pa_client_conf_load(pa_client_conf *c) {
FILE *f = NULL; FILE *f = NULL;
char *fn = NULL; char *fn = NULL;
int r = -1;
/* Prepare the configuration parse table */ /* Prepare the configuration parse table */
pa_config_item table[] = { pa_config_item table[] = {
@ -114,19 +113,13 @@ int pa_client_conf_load(pa_client_conf *c) {
{ NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL },
}; };
if (!(f = pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn))) f = pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn);
if (errno != ENOENT) if (!f)
goto finish; return;
r = f ? pa_config_parse(fn, f, table, NULL, NULL) : 0; pa_config_parse(fn, f, table, NULL, NULL);
finish:
pa_xfree(fn); pa_xfree(fn);
fclose(f);
if (f)
fclose(f);
return r;
} }
int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie_length) { int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie_length) {
@ -190,7 +183,7 @@ int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie
return -1; return -1;
} }
int pa_client_conf_env(pa_client_conf *c) { void pa_client_conf_env(pa_client_conf *c) {
char *e; char *e;
if ((e = getenv(ENV_DEFAULT_SINK))) { if ((e = getenv(ENV_DEFAULT_SINK))) {
@ -220,8 +213,6 @@ int pa_client_conf_env(pa_client_conf *c) {
pa_xfree(c->cookie_file_from_env); pa_xfree(c->cookie_file_from_env);
c->cookie_file_from_env = pa_xstrdup(e); c->cookie_file_from_env = pa_xstrdup(e);
} }
return 0;
} }
void pa_client_conf_set_cookie_file_from_application(pa_client_conf *c, const char *cookie_file) { void pa_client_conf_set_cookie_file_from_application(pa_client_conf *c, const char *cookie_file) {

View file

@ -49,7 +49,7 @@ void pa_client_conf_free(pa_client_conf *c);
/* Load the configuration data from the client configuration file, overwriting /* Load the configuration data from the client configuration file, overwriting
* the current settings in *c. */ * the current settings in *c. */
int pa_client_conf_load(pa_client_conf *c); void pa_client_conf_load(pa_client_conf *c);
/* Load the cookie from the cookie sources specified in the configuration, or /* Load the cookie from the cookie sources specified in the configuration, or
* if nothing is specified or none of the sources work, load the cookie from * if nothing is specified or none of the sources work, load the cookie from
@ -59,7 +59,7 @@ int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie
/* Load the configuration data from the environment of the current /* Load the configuration data from the environment of the current
process, overwriting the current settings in *c. */ process, overwriting the current settings in *c. */
int pa_client_conf_env(pa_client_conf *c); void pa_client_conf_env(pa_client_conf *c);
void pa_client_conf_set_cookie_file_from_application(pa_client_conf *c, const char *cookie_file); void pa_client_conf_set_cookie_file_from_application(pa_client_conf *c, const char *cookie_file);

View file

@ -152,15 +152,8 @@ int main(int argc, char *argv[]) {
char hx[PA_NATIVE_COOKIE_LENGTH*2+1]; char hx[PA_NATIVE_COOKIE_LENGTH*2+1];
assert(conf); assert(conf);
if (pa_client_conf_load(conf) < 0) { pa_client_conf_load(conf);
fprintf(stderr, _("Failed to load client configuration file.\n")); pa_client_conf_env(conf);
goto finish;
}
if (pa_client_conf_env(conf) < 0) {
fprintf(stderr, _("Failed to read environment configuration data.\n"));
goto finish;
}
pa_x11_del_prop(xcb, screen, "PULSE_SERVER"); pa_x11_del_prop(xcb, screen, "PULSE_SERVER");
pa_x11_del_prop(xcb, screen, "PULSE_SINK"); pa_x11_del_prop(xcb, screen, "PULSE_SINK");