Skip to content

Commit 5efd158

Browse files
author
Yang, Xiao
committed
[hal] fix the void * pointer calculation issue
Signed-off-by: Yang, Xiao <[email protected]>
1 parent 872a32f commit 5efd158

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

build-rules/_rules-top.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ one:
7171
ALL_LIBS="$(strip $(foreach V,$(SUBDIRS),$(LIBA_TARGET_$(V))))" \
7272
ALL_PROG="$(strip $(foreach V,$(SUBDIRS),$(TARGET_$(V))))" \
7373
COMP_LIB_OBJS="$(COMP_LIB_OBJS)" \
74-
bash $(RULE_DIR)/scripts/gen_one_makefile.sh $(STAMP_ONE_MK)
74+
bash $(RULE_DIR)/scripts/gen_one_makefile.sh
7575

7676
config:
7777

build-rules/scripts/gen_one_makefile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/bash
22

3-
TARGET_FILE=$1
3+
TARGET_FILE=${OUTPUT_DIR}/.one_makefile
44
rm -f ${TARGET_FILE}
55

66
CONFIG_VERNDOR=$(grep -m 1 "VENDOR *:" .config|awk '{ print $NF }')

src/board/config.xboard.make

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CONFIG_ENV_CFLAGS += -DSTM32L496xx \
55
--cpu=Cortex-M4 \
66
--apcs=interwork \
77
--split_sections
8-
CONFIG_ENV_CFLAGS += -c --c99 -D__MICROLIB -g --gnu --library_type=microlib -W -Ospace -O3 -Isrc/infra/stdc/armlibc
8+
CONFIG_ENV_CFLAGS += -c --c99 -D__MICROLIB -g --gnu --library_type=microlib -W -Ospace -O3 -Iprebuilt/extra/stdc/armlibc
99
OVERRIDE_AR:=armar -rcs
1010

1111
else ifeq ($(COMPILER),iar)
@@ -14,7 +14,7 @@ CONFIG_ENV_CFLAGS += -DSTM32L496xx \
1414
--cpu=Cortex-M4 \
1515
--cpu_mode=thumb \
1616
--endian=little
17-
CONFIG_ENV_CFLAGS += --vla -e --dlib_config=full -D_TIMESPEC_DEFINED --silent --only_stdout --no_warnings --diag_warning=Pe167,Pe144,Pe513 -Ohz -Isrc/infra/stdc/iarlibc
17+
CONFIG_ENV_CFLAGS += --vla -e --dlib_config=full -D_TIMESPEC_DEFINED --silent --only_stdout --no_warnings --diag_warning=Pe167,Pe144,Pe513 -Ohz -Iprebuilt/extra/stdc/iarlibc
1818
OVERRIDE_AR:=iarchive --create
1919

2020
else

src/protocol/http/iotx_http_api.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,22 @@ static int http_report_func(void *handle, const char *topic_name, int req_ack, v
145145
{
146146
iotx_http_message_param_t msg_param;
147147
char request_buf[1024];
148+
char topic_path[100];
149+
148150
if (handle == NULL || topic_name == NULL || data == NULL) {
149151
http_err("params err");
150152
return -1;
151153
}
154+
155+
HAL_Snprintf(topic_path, sizeof(topic_path), "/topic%s", topic_name);
156+
152157
memset(&msg_param, 0, sizeof(iotx_http_message_param_t));
153158
msg_param.request_payload = (char *)data;
154159
msg_param.response_payload = request_buf;
155160
msg_param.timeout_ms = CONFIG_MID_HTTP_TIMEOUT;
156161
msg_param.request_payload_len = len;
157162
msg_param.response_payload_len = 1024;
158-
msg_param.topic_path = (char *)topic_name;
163+
msg_param.topic_path = topic_path;
159164

160165
return IOT_HTTP_SendMessage(handle, &msg_param);
161166
}
@@ -193,6 +198,10 @@ void *IOT_HTTP_Init(iotx_http_param_t *pInitParams)
193198

194199
p_devinfo = pInitParams->device_info;
195200

201+
HAL_SetProductKey(p_devinfo->product_key);
202+
HAL_SetDeviceName(p_devinfo->device_name);
203+
HAL_SetDeviceSecret(p_devinfo->device_secret);
204+
196205
iotx_http_context = (iotx_http_t *)HTTP_API_MALLOC(sizeof(iotx_http_t));
197206

198207
if (NULL == iotx_http_context) {
@@ -481,12 +490,22 @@ int IOT_HTTP_DeviceNameAuth(void *handle)
481490
iotx_set_report_func(http_report_func);
482491
/* report module id */
483492
ret = iotx_report_mid(iotx_http_context);
484-
// /* report module id */
485-
// ret = iotx_http_report_mid(iotx_http_context);
486493
if (SUCCESS_RETURN != ret) {
487494
http_err("Send ModuleId message to server(Http) failed, ret = %d", ret);
488495
goto do_exit;
489496
}
497+
/* report device information */
498+
ret = iotx_report_devinfo(iotx_http_context);
499+
if (SUCCESS_RETURN != ret) {
500+
http_err("Send devinfo message to server(Http) failed, ret = %d", ret);
501+
goto do_exit;
502+
}
503+
/* report firmware */
504+
ret = iotx_report_firmware_version(iotx_http_context);
505+
if (SUCCESS_RETURN != ret) {
506+
http_err("Send firmware message to server(Http) failed, ret = %d", ret);
507+
goto do_exit;
508+
}
490509

491510
ret = 0;
492511

src/ref-impl/hal/ssl/mbedtls/HAL_TLS_mbedtls.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,14 @@ static int mbedtls_net_connect_timeout(mbedtls_net_context *ctx, const char *hos
274274

275275
void *_SSLCalloc_wrapper(size_t n, size_t size)
276276
{
277-
void *buf = NULL;
277+
unsigned char *buf = NULL;
278278
mbedtls_mem_info_t *mem_info = NULL;
279279

280280
if (n == 0 || size == 0) {
281281
return NULL;
282282
}
283283

284-
buf = g_ssl_hooks.malloc(n * size + sizeof(mbedtls_mem_info_t));
284+
buf = (unsigned char *)(g_ssl_hooks.malloc(n * size + sizeof(mbedtls_mem_info_t)));
285285
if (NULL == buf) {
286286
return NULL;
287287
} else {
@@ -311,7 +311,7 @@ void _SSLFree_wrapper(void *ptr)
311311
return;
312312
}
313313

314-
mem_info = ptr - sizeof(mbedtls_mem_info_t);
314+
mem_info = (mbedtls_mem_info_t *)((unsigned char *)ptr - sizeof(mbedtls_mem_info_t));
315315
if (mem_info->magic != MBEDTLS_MEM_INFO_MAGIC) {
316316
hal_info("Warning - invalid mem info magic: 0x%x\r\n", mem_info->magic);
317317
return;

0 commit comments

Comments
 (0)