buglwIP - A Lightweight TCP/IP stack - Bugs: bug #61333, Error in preprocessor logic...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #61333: Error in preprocessor logic setting ALTCP_MBEDTLS_PLATFORM_ALLOC

Submitted by:  Tom Collins <tomlogic>
Submitted on:  Tue 12 Oct 2021 03:11:18 AM UTC  
 
Category:  apps Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  Simon Goldschmidt <goldsimon>
Open/Closed:  Closed Planned Release:  2.2.0
lwIP version:  2.1.1

Fri 12 Nov 2021 09:31:45 PM UTC, comment #1: 

Fixed, thanks for reporting!

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 12 Oct 2021 03:11:18 AM UTC, original submission:  

I'm using lwIP as part of Silicon Labs's Gecko SDK, and it defines macros for mbedtls_free and mbedtls_calloc, but the compiler then throws an error when code in altcp_tls_mbedtls_mem.c tries to call mbedtls_platform_set_calloc_free().

Current code in altcp_tls_mbedtls_mem.c:

#if defined(MBEDTLS_PLATFORM_MEMORY) && \
   (!defined(MBEDTLS_PLATFORM_FREE_MACRO) || \
    defined(MBEDTLS_PLATFORM_CALLOC_MACRO))
#define ALTCP_MBEDTLS_PLATFORM_ALLOC 1
#else
#define ALTCP_MBEDTLS_PLATFORM_ALLOC 0
#endif

Recommended replacement (added ! before check for calloc macro):

#if defined(MBEDTLS_PLATFORM_MEMORY) && \
   (!defined(MBEDTLS_PLATFORM_FREE_MACRO) || \
    !defined(MBEDTLS_PLATFORM_CALLOC_MACRO))
#define ALTCP_MBEDTLS_PLATFORM_ALLOC 1
#else
#define ALTCP_MBEDTLS_PLATFORM_ALLOC 0
#endif

I'm basing this on code seen in platform.h:

#if defined(MBEDTLS_PLATFORM_MEMORY)
#if defined(MBEDTLS_PLATFORM_FREE_MACRO) && \
    defined(MBEDTLS_PLATFORM_CALLOC_MACRO)
#define mbedtls_free       MBEDTLS_PLATFORM_FREE_MACRO
#define mbedtls_calloc     MBEDTLS_PLATFORM_CALLOC_MACRO

Inverting the logic of the second #if should be "!defined || !defined".

Tom Collins <tomlogic>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by tomlogic (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-12 goldsimon StatusNone => Fixed
        Assigned toNone => goldsimon
        Open/ClosedOpen => Closed
        Planned ReleaseNone => 2.2.0

    Back to the top


    Powered by Savane 3.7