1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

lws-struct: json and sqlite on 32-bit OS

Test that we can handle int -1 correctly on sqlite and
greater than 32-bit unsigned on json with ull
This commit is contained in:
Andy Green 2021-01-05 09:23:44 +00:00
parent cc5a802b0d
commit 815b9074fc
2 changed files with 4 additions and 12 deletions

View file

@ -74,13 +74,13 @@ lws_struct_sq3_deser_cb(void *priv, int cols, char **cv, char **cn)
if (map->aux == sizeof(int)) {
int *pi;
pi = (int *)(u + map->ofs);
*pi = atoi(cv[n]);
*pi = (int)atoll(cv[n]); /* 32-bit OS */
break;
}
if (map->aux == sizeof(long)) {
long *pl;
pl = (long *)(u + map->ofs);
*pl = atol(cv[n]);
*pl = (long)atoll(cv[n]); /* 32-bit OS */
break;
}
{

View file

@ -38,11 +38,7 @@ static const char * const test2_json =
"},"
"\"frequency\":" "11,"
"\"arg1\":" "\"val2\","
#if defined(_WIN32)
"\"arg2\":" "2147483647,"
#else
"\"arg2\":" "1420887242594,"
#endif
"\"priority\":" "3,"
"\"ssid\":" "\"\\\"nw1\\\"\""
"}"
@ -55,11 +51,7 @@ static const char * const test2_json_expected =
"\"frequency\":0,\"arg2\":0,\"priority\":1},"
"{\"creds\":{\"key1\":\"\\u0022xxxxxxxxxxxxx\\u0022\"},"
"\"arg1\":\"val2\",\"ssid\":\"\\u0022nw1\\u0022\","
#if defined(_WIN32)
"\"frequency\":11,\"arg2\":2147483647,\"priority\":3}]}"
#else
"\"frequency\":11,\"arg2\":1420887242594,\"priority\":3}]}"
#endif
;
/*
@ -87,7 +79,7 @@ typedef struct t2_config {
const char *arg1;
const char *ssid;
unsigned int frequency;
unsigned long arg2;
unsigned long long arg2;
unsigned int priority;
} t2_config_t;
@ -148,7 +140,7 @@ t2_config_dump(struct lws_dll2 *d, void *user)
lwsl_notice("%s: ssid '%s'\n", __func__, c->ssid);
lwsl_notice("%s: freq %d\n", __func__, c->frequency);
lwsl_notice("%s: arg2 %lu\n", __func__, c->arg2);
lwsl_notice("%s: arg2 %llu\n", __func__, c->arg2);
lwsl_notice("%s: priority %d\n", __func__, c->priority);
lwsl_notice("%s: key1: %s, key2: %s\n", __func__,