Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC warning fix #4867

Merged
merged 13 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/libshout-idjc/src/common/avl/avl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ avl_verify_rank (avl_node * node)
num_right = avl_verify_rank (node->right);
}
if (AVL_GET_RANK (node) != num_left + 1) {
fprintf (stderr, "invalid rank at node %ld\n", (long) node->key);
fprintf (stderr, "invalid rank at node %p\n", node->key);
exit (1);
}
return (num_left + num_right + 1);
Expand Down
16 changes: 8 additions & 8 deletions lib/libshout-idjc/src/common/httpp/encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ ssize_t __copy_buffer(void *dst, void **src, size_t *boffset, size_t *blen, size
*blen = 0;
}

return todo;
return (ssize_t)todo;
}

/* try to flush output buffers */
Expand Down Expand Up @@ -326,7 +326,7 @@ ssize_t httpp_encoding_pending(httpp_encoding_t *self)
return -1;
if (!self->buf_write_encoded)
return 0;
return self->buf_write_encoded_len - self->buf_write_encoded_offset;
return (ssize_t)(self->buf_write_encoded_len - self->buf_write_encoded_offset);
}

/* Attach meta data to the stream.
Expand Down Expand Up @@ -565,11 +565,11 @@ static ssize_t __enc_chunked_read(httpp_encoding_t *self, void *buf, size_t len,
if (*c == '"') {
in_quote = 1;
} else if (*c == ';' && offset_extentions == -1) {
offset_extentions = i;
offset_extentions = (ssize_t)i;
} else if (*c == '\r') {
offset_CR = i;
offset_CR = (ssize_t)i;
} else if (*c == '\n' && offset_CR == (ssize_t)(i - 1)) {
offset_LF = i;
offset_LF = (ssize_t)i;
break;
}
}
Expand Down Expand Up @@ -760,8 +760,8 @@ static ssize_t __enc_chunked_write(httpp_encoding_t *self, const void *buf, size
extensions = __enc_chunked_write_extensions(self);

/* 2 = end of header and tailing "\r\n" */
header_length = strlen(encoded_length) + (extensions ? strlen(extensions) : 0) + 2;
total_chunk_size = header_length + len + 2;
header_length = (ssize_t)(strlen(encoded_length) + (extensions ? strlen(extensions) : 0) + 2);
total_chunk_size = header_length + (ssize_t)(len + 2);
if (!buf)
total_chunk_size += 2;

Expand All @@ -783,5 +783,5 @@ static ssize_t __enc_chunked_write(httpp_encoding_t *self, const void *buf, size
if (extensions)
free(extensions);

return len;
return (ssize_t)len;
}
10 changes: 5 additions & 5 deletions lib/libshout-idjc/src/common/httpp/httpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static void parse_headers(http_parser_t *parser, char **line, int lines)
whitespace = 0;
name = line[l];
value = NULL;
slen = strlen(line[l]);
slen = (int)strlen(line[l]);
for (i = 0; i < slen; i++) {
if (line[l][i] == ':') {
whitespace = 1;
Expand Down Expand Up @@ -165,7 +165,7 @@ int httpp_parse_response(http_parser_t *parser, const char *http_data, unsigned
/* In this case, the first line contains:
* VERSION RESPONSE_CODE MESSAGE, such as HTTP/1.0 200 OK
*/
slen = strlen(line[0]);
slen = (int)strlen(line[0]);
version = line[0];
for(i=0; i < slen; i++) {
if(line[0][i] == ' ') {
Expand Down Expand Up @@ -218,7 +218,7 @@ static int hex(char c)

static char *url_escape(const char *src)
{
int len = strlen(src);
int len = (int)strlen(src);
unsigned char *decoded;
int i;
char *dst;
Expand Down Expand Up @@ -277,7 +277,7 @@ static void parse_query(http_parser_t *parser, char *query)
if(!query || !*query)
return;

len = strlen(query);
len = (int)strlen(query);

while(i<len) {
switch(query[i]) {
Expand Down Expand Up @@ -330,7 +330,7 @@ int httpp_parse(http_parser_t *parser, const char *http_data, unsigned long len)
*/
where = 0;
whitespace = 0;
slen = strlen(line[0]);
slen = (int)strlen(line[0]);
req_type = line[0];
for (i = 0; i < slen; i++) {
if (line[0][i] == ' ') {
Expand Down
8 changes: 4 additions & 4 deletions lib/libshout-idjc/src/common/net/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ ssize_t sock_writev (sock_t sock, const struct iovec *iov, size_t count)

ssize_t sock_writev (sock_t sock, const struct iovec *iov, size_t count)
{
int i = count, accum = 0, ret;
int i = (int)count, accum = 0, ret;
const struct iovec *v = iov;

while (i)
Expand Down Expand Up @@ -367,7 +367,7 @@ int sock_write_bytes(sock_t sock, const void *buff, size_t len)
return SOCK_ERROR;
} */

return send(sock, buff, len, 0);
return send(sock, buff, (int)len, 0);
}

/* sock_write_string
Expand Down Expand Up @@ -469,7 +469,7 @@ int sock_read_bytes(sock_t sock, char *buff, size_t len)
if (!buff) return 0;
if (len <= 0) return 0;

return recv(sock, buff, len, 0);
return recv(sock, buff, (int)len, 0);
}

/* sock_read_line
Expand Down Expand Up @@ -569,7 +569,7 @@ int sock_connected (sock_t sock, int timeout)
FD_ZERO(&wfds);
FD_SET(sock, &wfds);

switch (select(sock + 1, NULL, &wfds, NULL, timeval))
switch (select((int)sock + 1, NULL, &wfds, NULL, timeval))
{
case 0:
return SOCK_TIMEOUT;
Expand Down
6 changes: 5 additions & 1 deletion lib/libshout-idjc/src/common/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ struct iovec
#endif

#ifndef sock_t
#ifdef _WIN32
#define sock_t SOCKET
#else
#define sock_t int
#endif
#endif

/* The following values are based on unix avoiding errno value clashes */
#define SOCK_SUCCESS 0
#define SOCK_ERROR (sock_t)-1
#define SOCK_ERROR -1
#define SOCK_TIMEOUT -2

/* sock connect macro */
Expand Down
8 changes: 2 additions & 6 deletions lib/libshout-idjc/src/common/thread/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
#include <log/log.h>
#endif

#ifdef _WIN32
#define __FUNCTION__ __FILE__
#endif

#ifdef THREAD_DEBUG
#define CATMODULE "thread"
#define LOG_ERROR(y) log_write(_logid, 1, CATMODULE "/", __FUNCTION__, y)
Expand Down Expand Up @@ -529,7 +525,7 @@ void thread_cond_timedwait_c(cond_t *cond, int millis, int line, char *file)
struct timespec time;

time.tv_sec = millis/1000;
time.tv_nsec = (millis - time.tv_sec*1000)*1000000;
time.tv_nsec = (long)((millis - time.tv_sec*1000)*1000000);

pthread_mutex_lock(&cond->cond_mutex);
pthread_cond_timedwait(&cond->sys_cond, &cond->cond_mutex, &time);
Expand Down Expand Up @@ -606,7 +602,7 @@ void thread_exit_c(long val, int line, char *file)
_mutex_unlock(&_threadtree_mutex);
}

pthread_exit ((void*)val);
pthread_exit ((void*)(size_t)val);
}

/* sleep for a number of microseconds */
Expand Down
6 changes: 3 additions & 3 deletions lib/libshout-idjc/src/common/timing/timing.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ void timing_sleep(uint64_t sleeptime)
{
struct timeval sleeper;

sleeper.tv_sec = sleeptime / 1000;
sleeper.tv_usec = (sleeptime % 1000) * 1000;
sleeper.tv_sec = (long)(sleeptime / 1000);
sleeper.tv_usec = (long)((sleeptime % 1000) * 1000);

/* NOTE:
* This should be 0 for the first argument. The linux manpage
* says so. The solaris manpage also says this is a legal
* value. If you think differerntly, please provide references.
*/
#ifdef WIN32
Sleep(sleeptime);
Sleep((DWORD)sleeptime);
#else
select(1, NULL, NULL, NULL, &sleeper);
#endif
Expand Down
18 changes: 9 additions & 9 deletions lib/libshout-idjc/src/format_mpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static int open_mpeg(shout_t *self, size_t header_size, int (*reader)(const uint
self->send = send_mpeg;
self->close = close_mpeg;

mpeg_data->header_size = header_size;
mpeg_data->header_size = (int)header_size;
mpeg_data->header_read = reader;

return SHOUTERR_SUCCESS;
Expand All @@ -146,7 +146,7 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len)
pos = 0;
start = 0;
error = 0;
end = len - 1;
end = (int)len - 1;

/* finish the previous frame */
if (mpeg_data->frame_left > 0) {
Expand All @@ -157,8 +157,8 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len)
pos += mpeg_data->frame_left;
mpeg_data->frame_left = 0;
} else {
mpeg_data->frame_left -= len;
pos = len;
mpeg_data->frame_left -= (unsigned int)len;
pos = (unsigned long)len;
}
}

Expand All @@ -174,7 +174,7 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len)

buff = bridge_buff;
len += mpeg_data->header_bridges;
end = len - 1;
end = (int)len - 1;

mpeg_data->header_bridges = 0;
}
Expand All @@ -187,7 +187,7 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len)
if (mpeg_data->header_read(&buff[pos], &mh)) {
if (error) {
start = pos;
end = len - 1;
end = (int)len - 1;
error = 0;
}

Expand All @@ -200,8 +200,8 @@ static int send_mpeg(shout_t *self, const unsigned char *buff, size_t len)
mpeg_data->frames++;
pos += mh.framesize;
} else {
mpeg_data->frame_left = mh.framesize - (len - pos);
pos = len;
mpeg_data->frame_left = (unsigned int)(mh.framesize - (len - pos));
pos = (unsigned long)len;
}
} else {
/* there was an error
Expand Down Expand Up @@ -324,7 +324,7 @@ static int adts_header(const uint8_t *window, header_digest_t *mh)
return 0;

/* make sure frame length is sane */
if (mh->framesize < (h.protection_absent ? MIN_ADTS_HEADER_SIZE : MAX_ADTS_HEADER_SIZE))
if (mh->framesize < (unsigned int)(h.protection_absent ? MIN_ADTS_HEADER_SIZE : MAX_ADTS_HEADER_SIZE))
return 0;

return 1;
Expand Down
4 changes: 2 additions & 2 deletions lib/libshout-idjc/src/format_ogg.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ static int send_ogg(shout_t *self, const unsigned char *data, size_t len)
char *buffer;
ogg_page page;

buffer = ogg_sync_buffer(&ogg_data->oy, len);
buffer = ogg_sync_buffer(&ogg_data->oy, (long)len);
memcpy(buffer, data, len);
ogg_sync_wrote(&ogg_data->oy, len);
ogg_sync_wrote(&ogg_data->oy, (long)len);

while (ogg_sync_pageout(&ogg_data->oy, &page) == 1) {
if (ogg_page_bos(&page)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/libshout-idjc/src/proto_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
char *shout_http_basic_authorization(shout_t *self)
{
char *out, *in;
int len;
size_t len;

if (!self || !self->user || !self->password)
return NULL;
Expand Down
12 changes: 8 additions & 4 deletions lib/libshout-idjc/src/proto_roaraudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
# include <arpa/inet.h>
#endif

#ifdef _WIN32
#include <process.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -131,10 +135,10 @@ static int shout_create_roaraudio_request_ident(shout_t *self)
/* version number (1). */
data[0] = 1;
/* PID */
data[1] = (pid & 0xFF000000UL) >> 24;
data[2] = (pid & 0x00FF0000UL) >> 16;
data[3] = (pid & 0x0000FF00UL) >> 8;
data[4] = (pid & 0x000000FFUL) >> 0;
data[1] = (uint8_t)((pid & 0xFF000000UL) >> 24);
data[2] = (uint8_t)((pid & 0x00FF0000UL) >> 16);
data[3] = (uint8_t)((pid & 0x0000FF00UL) >> 8);
data[4] = (uint8_t)((pid & 0x000000FFUL) >> 0);
/* agent name */
memcpy(data + 5, agent, datalen - 5);

Expand Down
4 changes: 2 additions & 2 deletions lib/libshout-idjc/src/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int shout_queue_data(shout_queue_t *queue, const unsigned char *data, size_t len

plen = len > SHOUT_BUFSIZE - buf->len ? SHOUT_BUFSIZE - buf->len : len;
memcpy(buf->data + buf->len, data, plen);
buf->len += plen;
buf->len += (unsigned int)(plen);
data += plen;
len -= plen;
queue->len += plen;
Expand Down Expand Up @@ -143,5 +143,5 @@ ssize_t shout_queue_collect(shout_buf_t *queue, char **buf)
pos += node->len;
}

return len;
return (ssize_t)len;
}
10 changes: 5 additions & 5 deletions lib/libshout-idjc/src/shout.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ ssize_t shout_send_raw(shout_t *self, const unsigned char *data, size_t len)
if (self->error != SHOUTERR_SUCCESS)
return self->error;
}
return len;
return (ssize_t)len;
}

self->error = shout_queue_data(&self->wqueue, data, len);
Expand All @@ -266,7 +266,7 @@ ssize_t shout_send_raw(shout_t *self, const unsigned char *data, size_t len)

ret = send_queue(self);
if (ret == SHOUTERR_SUCCESS || (len && ret == SHOUTERR_BUSY))
return len;
return (ssize_t)len;

return ret;
}
Expand Down Expand Up @@ -305,7 +305,7 @@ int shout_delay(shout_t *self)
if (self->senttime == 0)
return 0;

return self->senttime / 1000 - (timing_get_time() - self->starttime);
return (int)(self->senttime / 1000 - (timing_get_time() - self->starttime));
}

shout_metadata_t *shout_metadata_new(void)
Expand Down Expand Up @@ -1432,12 +1432,12 @@ static int try_write(shout_t *self, const void *data_p, size_t len)
if (ret < 0) {
if (shout_conn_recoverable(self)) {
self->error = SHOUTERR_BUSY;
return pos;
return (int)pos;
}
self->error = SHOUTERR_SOCKET;
return ret;
}
return pos;
return (int)pos;
}

ssize_t shout_conn_read(shout_t *self, void *buf, size_t len)
Expand Down
Loading