cli-command.c : pa_module_load failed case is not filtered by if condition
As I checked an issue that pulseaudio is not re-spawned when module load is failed, I found below code
425 static int pa_cli_command_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
426 const char *name;
427 pa_error_code_t err;
...
440 if ((err = pa_module_load(&m, c, name, pa_tokenizer_get(t, 2))) < 0) {
441 if (err == PA_ERR_EXIST) {
442 pa_strbuf_puts(buf, "Module already loaded; ignoring.\n");
443 } else {
444 pa_strbuf_puts(buf, "Module load failed.\n");
445 return -1;
446 }
447 }
448
449 return 0;
450 }
And pa_error_code_t is defined as below
470 /** Error values as used by pa_context_errno(). Use pa_strerror() to convert these values to human readable strings */
471 typedef enum pa_error_code {
472 PA_OK = 0, /**< No error */
473 PA_ERR_ACCESS, /**< Access failure */
474 PA_ERR_COMMAND, /**< Unknown command */
475 PA_ERR_INVALID, /**< Invalid argument */
476 PA_ERR_EXIST, /**< Entity exists */
477 PA_ERR_NOENTITY, /**< No such entity */
478 PA_ERR_CONNECTIONREFUSED, /**< Connection refused */
...
499 PA_ERR_MAX /**< Not really an error but the first invalid error code */
500 } pa_error_code_t;
It looks that err could not be less than 0 so that pa_cli_command_load would return 0 always
Is there any reason for this condition or anything I misunderstood?
Edited by GG Kim