fixed some (mostly Windows) warnings

This commit is contained in:
Martin Pulec
2022-02-01 11:52:09 +01:00
parent dbd7332b4c
commit cec2f43b32
14 changed files with 50 additions and 36 deletions

View File

@@ -38,6 +38,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#endif
#include <string>

View File

@@ -403,6 +403,9 @@ bool audio_frame2::resample([[maybe_unused]] audio_frame2_resampler & resampler_
channels = move(new_channels);
return true;
#else
UNUSED(resampler_state.resample_from);
UNUSED(resampler_state.resample_to);
UNUSED(resampler_state.resample_ch_count);
LOG(LOG_LEVEL_ERROR) << "Audio frame resampler: cannot resample, SpeexDSP was not compiled in!\n";
return false;
#endif

View File

@@ -277,6 +277,7 @@ void ShowMessage(int level, char *msg);
#define CLOSESOCKET closesocket
#undef ATTRIBUTE
#ifdef _MSC_VER
#define ATTRIBUTE(a)
#else

View File

@@ -290,7 +290,7 @@ static struct response *change_replica_type(struct hd_rum_translator_state *s,
static VOID CALLBACK wsa_deleter(DWORD /* dwErrorCode */,
DWORD /* dwNumberOfBytesTransfered */,
LPOVERLAPPED lpOverlapped, long unsigned int) {
struct wsa_aux_storage *aux = (struct wsa_aux_storage *) ((char *) lpOverlapped->hEvent + OFFSET);
struct wsa_aux_storage *aux = (struct wsa_aux_storage *)(void *) ((char *) lpOverlapped->hEvent + OFFSET);
if (--aux->ref == 0) {
free(aux->overlapped);
free(lpOverlapped->hEvent);
@@ -446,7 +446,7 @@ static void *writer(void *arg)
ref++;
}
}
struct wsa_aux_storage *aux = (struct wsa_aux_storage *) ((char *) s->qhead->buf + OFFSET);
struct wsa_aux_storage *aux = (struct wsa_aux_storage *)(void *) ((char *) s->qhead->buf + OFFSET);
memset(aux, 0, sizeof *aux);
aux->overlapped = (WSAOVERLAPPED *) calloc(ref, sizeof(WSAOVERLAPPED));
aux->ref = ref;
@@ -852,7 +852,6 @@ int main(int argc, char **argv)
}
uint64_t received_data = 0;
uint64_t received_pkts = 0;
struct timeval t0;
gettimeofday(&t0, NULL);
@@ -865,7 +864,6 @@ int main(int argc, char **argv)
&& (state.qtail->size = udp_recv_timeout(sock_in, state.qtail->buf, SIZE, &timeout)) > 0
&& !should_exit) {
received_data += state.qtail->size;
received_pkts += 1;
state.qtail = state.qtail->next;

View File

@@ -630,7 +630,7 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st
char plaintext[cdata->data->data_len]; // plaintext will be actually shorter
size_t main_hdr_len = PT_AUDIO_HAS_FEC(pt) ? sizeof(fec_payload_hdr_t) : sizeof(audio_payload_hdr_t);
if (PT_AUDIO_IS_ENCRYPTED(pt)) {
uint32_t encryption_hdr = ntohl(*(uint32_t *) (cdata->data->data + main_hdr_len));
uint32_t encryption_hdr = ntohl(*(uint32_t *)(void *) (cdata->data->data + main_hdr_len));
crypto_mode = (enum openssl_mode) (encryption_hdr >> 24);
if (crypto_mode == MODE_AES128_NONE || crypto_mode > MODE_AES128_MAX) {
log_msg(LOG_LEVEL_WARNING, "Unknown cipher mode: %d\n", (int) crypto_mode);

View File

@@ -50,10 +50,10 @@ struct rs : public fec {
rs(unsigned int k, unsigned int n);
rs(const char *cfg);
virtual ~rs();
std::shared_ptr<video_frame> encode(std::shared_ptr<video_frame> frame);
std::shared_ptr<video_frame> encode(std::shared_ptr<video_frame> frame) override;
virtual audio_frame2 encode(audio_frame2 const &) override;
bool decode(char *in, int in_len, char **out, int *len,
const std::map<int, int> &);
const std::map<int, int> &) override;
private:
int get_ss(int hdr_len, int len);

View File

@@ -2865,7 +2865,7 @@ rtp_send_data_hdr(struct rtp *session,
#else
d = buffer = (uint8_t *) malloc(20 + RTP_PACKET_HEADER_SIZE);
#endif
packet = (rtp_packet *) buffer;
packet = (rtp_packet *)(void *) buffer;
#ifdef WIN32
send_vector[0].buf = (char *) (buffer + RTP_PACKET_HEADER_SIZE);

View File

@@ -43,6 +43,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#endif // HAVE_CONFIG_H
#include "debug.h"
#include "perf.h"

View File

@@ -214,7 +214,7 @@ struct reported_statistics_cumul {
~reported_statistics_cumul() {
print();
}
long int last_buffer_number = -1; ///< last received buffer ID
long long int last_buffer_number = -1; ///< last received buffer ID
chrono::steady_clock::time_point t_last = chrono::steady_clock::now();
unsigned long int displayed = 0, dropped = 0, corrupted = 0, missing = 0;
atomic_ulong fec_ok = 0, fec_corrected = 0, fec_nok = 0;
@@ -242,7 +242,7 @@ struct reported_statistics_cumul {
}
void update(int buffer_number) {
if (last_buffer_number != -1) {
long int diff = buffer_number -
long long int diff = buffer_number -
((last_buffer_number + 1) & ((1U<<BUFNUM_BITS) - 1));
diff = (diff + (1U<<BUFNUM_BITS)) % (1U<<BUFNUM_BITS);
if (diff < (1U<<BUFNUM_BITS) / 2) {

View File

@@ -449,10 +449,18 @@ static int read_sos(struct jpeg_info *param, uint8_t** image)
int length = (int)read_2byte(*image);
length -= 2;
if (length == 0) {
log_msg(LOG_LEVEL_ERROR, "[JPEG] [Error] Wrong SOS length: %d\n", length);
return -1;
}
int comp_count = (int)read_byte(*image);
if ( comp_count != param->comp_count ) {
param->interleaved = false;
}
if (length < 1 + comp_count * 2 + 3) {
log_msg(LOG_LEVEL_ERROR, "[JPEG] [Error] Wrong SOS length: %d\n", length);
return -1;
}
// Collect the component-spec parameters
for ( int comp = 0; comp < comp_count; comp++ )

View File

@@ -337,7 +337,7 @@ static bool nat_pmp_add_mapping(natpmp_t *natpmp, int privateport, int publicpor
fd_set fds;
struct timeval timeout = { 0 };
FD_ZERO(&fds);
FD_SET(natpmp->s, &fds);
FD_SET((fd_t) natpmp->s, &fds);
r = getnatpmprequesttimeout(natpmp, &timeout);
if (r != 0) {
log_msg(LOG_LEVEL_ERROR, MOD_NAME "NAT PMP - getnatpmprequesttimeout returned %d (%s)\n",
@@ -398,7 +398,7 @@ static bool setup_nat_pmp(struct ug_nat_traverse *state, int video_rx_port, int
fd_set fds;
struct timeval timeout;
FD_ZERO(&fds);
FD_SET(natpmp.s, &fds);
FD_SET((fd_t) natpmp.s, &fds);
getnatpmprequesttimeout(&natpmp, &timeout);
r = select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
if(r<0) {

View File

@@ -1409,24 +1409,24 @@ static const struct {
const CHAR *pName;
const WCHAR *wszName;
codec_t ug_codec;
} BitCountMap[] = { &MEDIASUBTYPE_RGB1, 1, "RGB Monochrome", L"RGB Monochrome", VIDEO_CODEC_NONE,
&MEDIASUBTYPE_RGB4, 4, "RGB VGA", L"RGB VGA", VIDEO_CODEC_NONE,
&MEDIASUBTYPE_RGB8, 8, "RGB 8", L"RGB 8", VIDEO_CODEC_NONE,
&MEDIASUBTYPE_RGB565, 16, "RGB 565 (16 bit)", L"RGB 565 (16 bit)", VIDEO_CODEC_NONE,
&MEDIASUBTYPE_RGB555, 16, "RGB 555 (16 bit)", L"RGB 555 (16 bit)", VIDEO_CODEC_NONE,
&MEDIASUBTYPE_RGB24, 24, "RGB 24", L"RGB 24", BGR,
&MEDIASUBTYPE_RGB32, 32, "RGB 32", L"RGB 32", RGBA,
&MEDIASUBTYPE_ARGB32, 32, "ARGB 32", L"ARGB 32", VIDEO_CODEC_NONE,
&MEDIASUBTYPE_Overlay, 0, "Overlay", L"Overlay", VIDEO_CODEC_NONE,
&GUID_I420 , 12, "I420", L"I420", VIDEO_CODEC_NONE,
&MEDIASUBTYPE_YUY2, 12, "YUY2", L"YUY2", YUYV,
&GUID_R210, 12, "r210", L"r210", VIDEO_CODEC_NONE,
&GUID_v210, 12, "v210", L"v210", v210,
&GUID_V210, 12, "V210", L"V210", v210,
&MEDIASUBTYPE_UYVY, 12, "UYVY", L"UYVY", UYVY,
&GUID_HDYC, 12, "HDYC", L"HDYC", UYVY,
&MEDIASUBTYPE_MJPG, 0, "MJPG", L"MJPG", MJPG,
&GUID_NULL, 0, "UNKNOWN", L"UNKNOWN", VIDEO_CODEC_NONE
} BitCountMap[] = { { &MEDIASUBTYPE_RGB1, 1, "RGB Monochrome", L"RGB Monochrome", VIDEO_CODEC_NONE },
{ &MEDIASUBTYPE_RGB4, 4, "RGB VGA", L"RGB VGA", VIDEO_CODEC_NONE },
{ &MEDIASUBTYPE_RGB8, 8, "RGB 8", L"RGB 8", VIDEO_CODEC_NONE },
{ &MEDIASUBTYPE_RGB565, 16, "RGB 565 (16 bit)", L"RGB 565 (16 bit)", VIDEO_CODEC_NONE },
{ &MEDIASUBTYPE_RGB555, 16, "RGB 555 (16 bit)", L"RGB 555 (16 bit)", VIDEO_CODEC_NONE },
{ &MEDIASUBTYPE_RGB24, 24, "RGB 24", L"RGB 24", BGR },
{ &MEDIASUBTYPE_RGB32, 32, "RGB 32", L"RGB 32", RGBA },
{ &MEDIASUBTYPE_ARGB32, 32, "ARGB 32", L"ARGB 32", VIDEO_CODEC_NONE },
{ &MEDIASUBTYPE_Overlay, 0, "Overlay", L"Overlay", VIDEO_CODEC_NONE },
{ &GUID_I420 , 12, "I420", L"I420", VIDEO_CODEC_NONE },
{ &MEDIASUBTYPE_YUY2, 12, "YUY2", L"YUY2", YUYV },
{ &GUID_R210, 12, "r210", L"r210", VIDEO_CODEC_NONE },
{ &GUID_v210, 12, "v210", L"v210", v210 },
{ &GUID_V210, 12, "V210", L"V210", v210 },
{ &MEDIASUBTYPE_UYVY, 12, "UYVY", L"UYVY", UYVY },
{ &GUID_HDYC, 12, "HDYC", L"HDYC", UYVY },
{ &MEDIASUBTYPE_MJPG, 0, "MJPG", L"MJPG", MJPG },
{ &GUID_NULL, 0, "UNKNOWN", L"UNKNOWN", VIDEO_CODEC_NONE },
};
static codec_t get_ug_codec(const GUID *pSubtype)

View File

@@ -321,7 +321,7 @@ void * vidcap_testcard2_thread(void *arg)
#ifdef HAVE_LIBSDL_TTF
TTF_Font * font = NULL;
unsigned char *banner = malloc(vc_get_datalen(s->desc.width, BANNER_HEIGHT, RGBA));
uint32_t *banner = malloc(vc_get_datalen(s->desc.width, BANNER_HEIGHT, RGBA));
if(TTF_Init() == -1)
{
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unable to initialize SDL_ttf: %s\n",
@@ -412,15 +412,15 @@ void * vidcap_testcard2_thread(void *arg)
long xoff = ((long) s->desc.width - text->w) / 2;
long yoff = (BANNER_HEIGHT - text->h) / 2;
for (int i = 0 ; i < text->h; i++) {
uint32_t *d = (uint32_t*)banner + xoff + (i + yoff) * s->desc.width;
for (int j = 0 ; j < MIN(text->w, s->desc.width - xoff); j++) {
uint32_t *d = banner + xoff + (i + yoff) * s->desc.width;
for (int j = 0 ; j < MIN(text->w, (int) s->desc.width - xoff); j++) {
if (((char *)text->pixels) [i * text->pitch + j]) {
*d = 0x00000000U;
}
d++;
}
}
testcard_convert_buffer(RGBA, s->desc.color_spec, tmp + (s->desc.height - BANNER_MARGIN_BOTTOM - BANNER_HEIGHT) * vc_get_linesize(s->desc.width, s->desc.color_spec), banner, s->desc.width, BANNER_HEIGHT);
testcard_convert_buffer(RGBA, s->desc.color_spec, tmp + (s->desc.height - BANNER_MARGIN_BOTTOM - BANNER_HEIGHT) * vc_get_linesize(s->desc.width, s->desc.color_spec), (unsigned char *) banner, s->desc.width, BANNER_HEIGHT);
SDL_FreeSurface(text);
#endif

View File

@@ -2008,8 +2008,10 @@ static void vc_copylineRG48toR10k(unsigned char * __restrict dst, const unsigned
UNUSED(rshift);
UNUSED(gshift);
UNUSED(bshift);
const uint16_t *in = (const uint16_t *) src;
uint32_t *out = (uint32_t *) dst;
assert((uintptr_t) src % sizeof(uint16_t) == 0);
assert((uintptr_t) dst % sizeof(uint32_t) == 0);
const uint16_t *in = (const uint16_t *)(const void *) src;
uint32_t *out = (uint32_t *)(void *) dst;
OPTIMIZED_FOR (int x = 0; x <= dst_len - 4; x += 4) {
#ifdef WORDS_BIGENDIAN
*out++ = r << 22U | g << 12U | b << 2U | 0x3FU; /// @todo just a stub