mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-27 21:39:16 -05:00
[spotify] Coverity fixups
This commit is contained in:
parent
0fdca0587c
commit
cd4386228d
@ -51,7 +51,7 @@ path_to_media_id_and_type(struct sp_file *file)
|
|||||||
struct sp_channel *
|
struct sp_channel *
|
||||||
channel_get(uint32_t channel_id, struct sp_session *session)
|
channel_get(uint32_t channel_id, struct sp_session *session)
|
||||||
{
|
{
|
||||||
if (channel_id > sizeof(session->channels)/sizeof(session->channels)[0])
|
if (channel_id >= sizeof(session->channels)/sizeof(session->channels)[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (session->channels[channel_id].state == SP_CHANNEL_STATE_UNALLOCATED)
|
if (session->channels[channel_id].state == SP_CHANNEL_STATE_UNALLOCATED)
|
||||||
@ -148,6 +148,7 @@ channel_flush(struct sp_channel *channel)
|
|||||||
int fd = channel->audio_fd[0];
|
int fd = channel->audio_fd[0];
|
||||||
int flags;
|
int flags;
|
||||||
int got;
|
int got;
|
||||||
|
int ret;
|
||||||
|
|
||||||
evbuffer_drain(channel->audio_buf, -1);
|
evbuffer_drain(channel->audio_buf, -1);
|
||||||
|
|
||||||
@ -157,13 +158,18 @@ channel_flush(struct sp_channel *channel)
|
|||||||
if (flags == -1)
|
if (flags == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
||||||
|
if (ret < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
do
|
do
|
||||||
got = read(fd, buf, sizeof(buf));
|
got = read(fd, buf, sizeof(buf));
|
||||||
while (got > 0);
|
while (got > 0);
|
||||||
|
|
||||||
fcntl(fd, F_SETFL, flags);
|
ret = fcntl(fd, F_SETFL, flags);
|
||||||
|
if (ret < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,6 +207,10 @@ commands_base_new(struct event_base *evbase, command_exit_cb exit_cb)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
cmdbase = calloc(1, sizeof(struct commands_base));
|
cmdbase = calloc(1, sizeof(struct commands_base));
|
||||||
|
if (!cmdbase)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PIPE2
|
#ifdef HAVE_PIPE2
|
||||||
ret = pipe2(cmdbase->command_pipe, O_CLOEXEC);
|
ret = pipe2(cmdbase->command_pipe, O_CLOEXEC);
|
||||||
@ -370,6 +374,9 @@ commands_exec_async(struct commands_base *cmdbase, command_function func, void *
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
cmd = calloc(1, sizeof(struct command));
|
cmd = calloc(1, sizeof(struct command));
|
||||||
|
if (!cmd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
cmd->func = func;
|
cmd->func = func;
|
||||||
cmd->func_bh = NULL;
|
cmd->func_bh = NULL;
|
||||||
cmd->arg = arg;
|
cmd->arg = arg;
|
||||||
|
@ -620,7 +620,7 @@ response_aplogin_failed(uint8_t *payload, size_t payload_len, struct sp_session
|
|||||||
}
|
}
|
||||||
|
|
||||||
sp_errmsg = "(unknown login error)";
|
sp_errmsg = "(unknown login error)";
|
||||||
for (int i = 0; i < sizeof(sp_login_errors); i++)
|
for (int i = 0; i < sizeof(sp_login_errors)/sizeof(sp_login_errors[0]); i++)
|
||||||
{
|
{
|
||||||
if (sp_login_errors[i].errorcode != aplogin_failed->error_code)
|
if (sp_login_errors[i].errorcode != aplogin_failed->error_code)
|
||||||
continue;
|
continue;
|
||||||
|
@ -48,6 +48,7 @@ events for proceeding are activated directly.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "librespot-c-internal.h"
|
#include "librespot-c-internal.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
@ -833,6 +834,8 @@ librespotc_write(int fd, sp_progress_cb progress_cb, void *cb_arg)
|
|||||||
|
|
||||||
cmdargs = calloc(1, sizeof(struct sp_cmdargs));
|
cmdargs = calloc(1, sizeof(struct sp_cmdargs));
|
||||||
|
|
||||||
|
assert(cmdargs);
|
||||||
|
|
||||||
cmdargs->fd_read = fd;
|
cmdargs->fd_read = fd;
|
||||||
cmdargs->progress_cb = progress_cb;
|
cmdargs->progress_cb = progress_cb;
|
||||||
cmdargs->cb_arg = cb_arg;
|
cmdargs->cb_arg = cb_arg;
|
||||||
|
@ -351,9 +351,10 @@ request_endpoint(const char *uri)
|
|||||||
json_object *json_response = NULL;
|
json_object *json_response = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ctx = calloc(1, sizeof(struct http_client_ctx));
|
CHECK_NULL(L_SPOTIFY, ctx = calloc(1, sizeof(struct http_client_ctx)));
|
||||||
ctx->output_headers = calloc(1, sizeof(struct keyval));
|
CHECK_NULL(L_SPOTIFY, ctx->output_headers = calloc(1, sizeof(struct keyval)));
|
||||||
ctx->input_body = evbuffer_new();
|
CHECK_NULL(L_SPOTIFY, ctx->input_body = evbuffer_new());
|
||||||
|
|
||||||
ctx->url = uri;
|
ctx->url = uri;
|
||||||
|
|
||||||
snprintf(bearer_token, sizeof(bearer_token), "Bearer %s", spotify_credentials.access_token);
|
snprintf(bearer_token, sizeof(bearer_token), "Bearer %s", spotify_credentials.access_token);
|
||||||
@ -1091,7 +1092,9 @@ spotifywebapi_oauth_uri_get(const char *redirect_uri)
|
|||||||
if (param)
|
if (param)
|
||||||
{
|
{
|
||||||
uri_len = strlen(spotify_auth_uri) + strlen(param) + 3;
|
uri_len = strlen(spotify_auth_uri) + strlen(param) + 3;
|
||||||
uri = calloc(uri_len, sizeof(char));
|
|
||||||
|
CHECK_NULL(L_SPOTIFY, uri = calloc(uri_len, sizeof(char)));
|
||||||
|
|
||||||
snprintf(uri, uri_len, "%s/?%s", spotify_auth_uri, param);
|
snprintf(uri, uri_len, "%s/?%s", spotify_auth_uri, param);
|
||||||
|
|
||||||
free(param);
|
free(param);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user