Skip to content

Fix warnings emitted when compiling for mbedTLS and ESP_PLATFORM=1 #213

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
4 changes: 3 additions & 1 deletion core/pubnub_sync_subscribe_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ struct pubnub_subloop_descriptor pubnub_subloop_define(pubnub_t *p, char const *
struct pubnub_subloop_descriptor pubnub_sync_subloop_define(pubnub_t *p, char const *channel)
#endif
{
struct pubnub_subloop_descriptor rslt = { p, channel };
struct pubnub_subloop_descriptor rslt;
rslt.pbp = p;
rslt.channel = channel;
rslt.options = pubnub_subscribe_defopts();

return rslt;
Expand Down
23 changes: 18 additions & 5 deletions freertos/pbpal_resolv_and_connect_freertos_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t *pb)
{
struct sockaddr addr;

PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
PUBNUB_ASSERT_OPT((pb->state == PBS_READY) || (pb->state == PBS_WAIT_DNS_SEND) || (pb->state == PBS_WAIT_DNS_RCV));

addr.sin_port = htons(HTTP_PORT);

#if ESP_PLATFORM
struct sockaddr_in addr;

addr.sin_port = htons(HTTP_PORT);

PUBNUB_LOG_TRACE("pbpal_resolv_and_connect: gethostbyname(%s)\n",
PUBNUB_ORIGIN_SETTABLE ? pb->origin : PUBNUB_ORIGIN);

Expand All @@ -39,12 +39,24 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t *pb)
PUBNUB_LOG_ERROR("pbpal_resolv_and_connect: no address found!\n");
return pbpal_resolv_failed_processing;
}

pb->pal.socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (pb->pal.socket == SOCKET_INVALID) {
return pbpal_connect_resource_failure;
}
if (connect(pb->pal.socket, (const struct sockaddr*) &addr, sizeof addr) != 0) {
closesocket(pb->pal.socket);
pb->pal.socket = SOCKET_INVALID;
return pbpal_connect_failed;
}
#else
struct sockaddr addr;

addr.sin_port = htons(HTTP_PORT);
addr.sin_addr = gethostbyname(PUBNUB_ORIGIN_SETTABLE ? pb->origin : PUBNUB_ORIGIN);
if (addr.sin_addr == 0) {
return pbpal_resolv_failed_processing;
}
#endif

pb->pal.socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (pb->pal.socket == SOCKET_INVALID) {
Expand All @@ -55,6 +67,7 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t *pb)
pb->pal.socket = SOCKET_INVALID;
return pbpal_connect_failed;
}
#endif

{
TickType_t tmval = pdMS_TO_TICKS(pb->transaction_timeout_ms);
Expand Down
6 changes: 1 addition & 5 deletions freertos/pubnub_assert_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ void pubnub_assert_handler_abort(char const *s, char const *file, long line)
*/
taskDISABLE_INTERRUPTS();
{
/** In the debugger, user can change the value of this
variable to get out of the loop and continue processing.
*/
volatile int stay_blocked = 1;
while (stay_blocked) {
for (;;) {
#if INCLUDE_vTaskDelay
vTaskDelay(pdMS_TO_TICKS(1000));
#endif
Expand Down
1 change: 0 additions & 1 deletion freertos/pubnub_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ typedef Socket_t pb_socket_t;
#define socket(family, type, protocol) lwip_socket((family), (type), (protocol))
#define socket_connect(socket, addr, addrlen) lwip_connect((socket), (addr), (addrlen))
#define socket_setsockopt(socket, level, optname, optval, optlen) lwip_setsockopt((socket), (level), (optname), (optval), (optlen))
#define sockaddr sockaddr_in

typedef int pb_socket_t;

Expand Down
2 changes: 1 addition & 1 deletion mbedtls/pbpal_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#endif


static void pbntf_setup(void);
static void pbntf_setup(pubnub_t* pb);
static void options_setup(pubnub_t* pb);
static void buffer_setup(pubnub_t* pb);

Expand Down