Making sure no warnings are printed (except for getenv) on windows.

This commit is contained in:
2026-04-17 13:58:28 +02:00
parent ee33c72915
commit 89b084a6a7
6 changed files with 27 additions and 16 deletions

View File

@@ -92,7 +92,7 @@ const JSON &JSON::at(unsigned int index) const {
int JSON::length() const { int JSON::length() const {
if( Type == Class::Array ) if( Type == Class::Array )
return Internal.List->size(); return static_cast<int>(Internal.List->size());
else else
return -1; return -1;
} }
@@ -105,9 +105,9 @@ bool JSON::hasKey(const std::string &key) const {
int JSON::size() const { int JSON::size() const {
if( Type == Class::Object ) if( Type == Class::Object )
return Internal.Map->size(); return static_cast<int>(Internal.Map->size());
else if( Type == Class::Array ) else if( Type == Class::Array )
return Internal.List->size(); return static_cast<int>(Internal.List->size());
else else
return -1; return -1;
} }

Binary file not shown.

View File

@@ -63,6 +63,7 @@ static void event_cb(rkt_data_t *data)
free_data(data); free_data(data);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
const char *me = argv[0]; const char *me = argv[0];

View File

@@ -31,6 +31,10 @@
#define ALIVE_SLOT 4 #define ALIVE_SLOT 4
#define ALIVE_ACK_SLOT 5 #define ALIVE_ACK_SLOT 5
#ifdef _WIN32
#define strdup _strdup
#endif
//#define DEBUG //#define DEBUG
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
@@ -106,12 +110,12 @@ bool runRktWebview(Handle_t *handler)
char alive_slot[10]; char alive_slot[10];
char alive_ack_slot[10]; char alive_ack_slot[10];
sprintf(shm_size_str, "%d", static_cast<int>(handler->shm_size)); snprintf(shm_size_str, 30, "%d", static_cast<int>(handler->shm_size));
sprintf(command_slot, "%d", COMMAND_SLOT); snprintf(command_slot, 10, "%d", COMMAND_SLOT);
sprintf(command_result_slot, "%d", COMMAND_RESULT_SLOT); snprintf(command_result_slot, 10, "%d", COMMAND_RESULT_SLOT);
sprintf(event_slot, "%d", EVENT_SLOT); snprintf(event_slot, 10, "%d", EVENT_SLOT);
sprintf(alive_slot, "%d", ALIVE_SLOT); snprintf(alive_slot, 10, "%d", ALIVE_SLOT);
sprintf(alive_ack_slot, "%d", ALIVE_ACK_SLOT); snprintf(alive_ack_slot, 10, "%d", ALIVE_ACK_SLOT);
// run rktwebview_prg using the environment variable RKT_WEBVIEW_PRG // run rktwebview_prg using the environment variable RKT_WEBVIEW_PRG
@@ -316,7 +320,7 @@ void rkt_webview_init()
#else #else
#ifdef _WIN32 #ifdef _WIN32
DWORD p = GetCurrentProcessId(); DWORD p = GetCurrentProcessId();
sprintf(buf, "rktwebview-%ld", p); snprintf(buf, 1024, "rktwebview-%ld", p);
#else #else
pid_t p = getpid(); pid_t p = getpid();
sprintf(buf, "rktwebview-%x", p); sprintf(buf, "rktwebview-%x", p);

14
shm.cpp
View File

@@ -138,7 +138,7 @@ public:
first_i->prev = p_i; first_i->prev = p_i;
} }
i->prev = SHM_NULL; i->prev = SHM_NULL;
i->alloc_size = bytes; i->alloc_size = static_cast<int>(bytes);
*_first = p_i; *_first = p_i;
place = p_i + sizeof(ShmItem); place = p_i + sizeof(ShmItem);
@@ -152,8 +152,8 @@ public:
} else { } else {
*_used = u; *_used = u;
i->prev = SHM_NULL; i->prev = SHM_NULL;
i->size = bytes; i->size = static_cast<int>(bytes);
i->alloc_size = bytes; i->alloc_size = static_cast<int>(bytes);
i->next = *_first; i->next = *_first;
if (*_first != SHM_NULL) { if (*_first != SHM_NULL) {
ShmItem *first_i; ShmItem *first_i;
@@ -180,6 +180,7 @@ public:
ShmPlace p_i = place - sizeof(ShmItem); ShmPlace p_i = place - sizeof(ShmItem);
ShmItem *i; ShmItem *i;
ref(p_i, &i); ref(p_i, &i);
if (i == nullptr) return;
if (i->prev != SHM_NULL) { if (i->prev != SHM_NULL) {
ShmItem *prev_i; ShmItem *prev_i;
@@ -218,8 +219,9 @@ public:
public: public:
ShmApiBase(const char *name, size_t size, bool owner) { ShmApiBase(const char *name, size_t size, bool owner) {
char *buf = reinterpret_cast<char *>(malloc(strlen(name) + 50)); size_t buf_size = strlen(name) + 50;
sprintf(buf, "sem_%s", name); char *buf = reinterpret_cast<char *>(malloc(buf_size));
snprintf(buf, buf_size, "sem_%s", name);
_sem_name = _strdup(buf); _sem_name = _strdup(buf);
_mem_name = _strdup(name); _mem_name = _strdup(name);
::free(buf); ::free(buf);
@@ -495,7 +497,7 @@ public:
if (_owner) { if (_owner) {
*_first = SHM_NULL; *_first = SHM_NULL;
*_free_list = SHM_NULL; *_free_list = SHM_NULL;
*_used = sizeof(int) + sizeof(ShmItem *) + sizeof(ShmItem *) + slots_size; *_used = static_cast<int>(sizeof(int) + sizeof(ShmItem *) + sizeof(ShmItem *) + slots_size);
} }
} }
} }

View File

@@ -1,6 +1,10 @@
#include "shmqueue.h" #include "shmqueue.h"
#include <string.h> #include <string.h>
#ifdef _WIN32
#define sprintf sprintf_s
#endif
ShmQueue::ShmQueue(Shm *shm, ShmSlot slot, bool owner) ShmQueue::ShmQueue(Shm *shm, ShmSlot slot, bool owner)
{ {
_shm = shm; _shm = shm;