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

Submitter:  Tom Collins <tomlogic>
Submitted:  Tue 12 Oct 2021 03:11:18 AM UTC
   
 
Category:  apps Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  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>
Group administrator
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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

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)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    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.13-758e.
    Corresponding source code