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

Redefinition of functions with MBEDTLS_PLATFORM_MEMORY and MBEDTLS_PLATFORM_CALLOC_MACRO #1706

Closed
dhhome2006 opened this Issue Jun 7, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@dhhome2006

dhhome2006 commented Jun 7, 2018

Description

  • Type : Bug
  • Priority: Minor

Bug

OS
windows xp sp3, ubuntu

mbed TLS build:
Version : mbedtls-2.9.0-apache.tgz
Compiler: vs2010, gcc4.9

{{{
There is a compile error,

package : mbedtls-2.9.0-apache.tgz
file : platform.c
line : 40
condition : enable MBEDTLS_PLATFORM_MEMORY, MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_FREE_MACRO in config.h

current code:
#if defined(MBEDTLS_PLATFORM_MEMORY)

fixed code:
#if defined(MBEDTLS_PLATFORM_MEMORY) &&
(!defined(MBEDTLS_PLATFORM_CALLOC_MACRO) || !defined(MBEDTLS_PLATFORM_FREE_MACRO))

below is output snapshot in vs2010:
------ Build started: Project: mbedTLS, Configuration: Debug Win32 ------
platform.c
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(61): error C2365: 'calloc' : redefinition; previous definition was 'function'
c:\program files\microsoft visual studio 10.0\vc\include\stdlib.h(598) : see declaration of 'calloc'
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(62): error C2365: 'free' : redefinition; previous definition was 'function'
c:\program files\microsoft visual studio 10.0\vc\include\stdlib.h(599) : see declaration of 'free'
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(67): error C2106: '=' : left operand must be l-value
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(67): warning C4550: expression evaluates to a function which is missing an argument list
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(68): error C2106: '=' : left operand must be l-value
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(68): warning C4550: expression evaluates to a function which is missing an argument list
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Eric Tung, dhhome2006@gmail.com
}}}

@sbutcher-arm sbutcher-arm changed the title from a compile error to Redefinition of functions with MBEDTLS_PLATFORM_MEMORY and MBEDTLS_PLATFORM_CALLOC_MACRO Jun 8, 2018

@sbutcher-arm

This comment has been minimized.

Collaborator

sbutcher-arm commented Jun 8, 2018

Offhand, I'm not sure the design is supposed to accommodate this configuration. However - we'll look into it, and maybe it needs better documentation or more checks, if it isn't broken as it first appears.

Thanks for the feedback!

@dhhome2006

This comment has been minimized.

dhhome2006 commented Jun 8, 2018

In fact, we are using the memory pool.

{{{
#ifndef MBEDTLS_CONFIG_H
#define MBEDTLS_CONFIG_H

#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE 1
#endif

#include "../../../pro/pro_util/pro_a.h"
#include <stdlib.h>

void*
PRO_CALLTYPE
ProCalloc(size_t count, size_t size);

void
PRO_CALLTYPE
ProFree(void* p);

#define MBEDTLS_PLATFORM_CALLOC_MACRO ProCalloc // from a pool
#define MBEDTLS_PLATFORM_FREE_MACRO ProFree // from a pool

...

}}}

@ciarmcom ciarmcom added the mirrored label Jun 8, 2018

@ciarmcom

This comment has been minimized.

Member

ciarmcom commented Jun 8, 2018

ARM Internal Ref: IOTSSL-2358

@RonEld

This comment has been minimized.

Contributor

RonEld commented Aug 19, 2018

from a brief look, this seems like a duplicate of #1642
please confirm

@sbutcher-arm

This comment has been minimized.

Collaborator

sbutcher-arm commented Nov 4, 2018

Closing as a duplicate of #882.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment