buglwIP - A Lightweight TCP/IP stack - Bugs: bug #55199, ppp: inefficient debug disable

 
 

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

bug #55199: ppp: inefficient debug disable

Submitter:  Sergey A. Borshch <dushevny>
Submitted:  Mon 10 Dec 2018 11:22:59 PM UTC
   
 
Category:  PPP Severity:  1 - Wish
Item Group:  Change Request Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

Fri 10 Jan 2020 10:19:25 PM UTC, comment #2: 

Applied that patch, see task #14798

Simon Goldschmidt <goldsimon>
Group administrator
Fri 10 Jan 2020 08:46:18 PM UTC, comment #1: 

Sylvain, would you be ok with changing the ppp_*() functions to ppp_*(()) macros? That way, the macros would ensure debug code is not linked when disabled.

The change in ppp_impl.h and utils.c is minimal, however, all occurrences of those calls are changed from () to (()). See attached patch.

(file #48199)

Simon Goldschmidt <goldsimon>
Group administrator
Mon 10 Dec 2018 11:22:59 PM UTC, original submission:  

Even in PPP debug output disabled by not defining PPP_DEBUG macro, ppp_dbglog(), ppp_info(), ppp_notice() etc. functions calls ppp_logit() function, which allocates 1024 bytes on stack, wastes CPU time in ppp_vslprintf() and calls ppp_log_write(), where debug output is actually disabled by PPPDEBUG() defined to empty code. Additionally all ppp debug strings are also linked into resulting executable. Replacing debug functions declaration in ppp_impl.h with
#if PPP_DEBUG
void ppp_dbglog(const char fmt, ...);    / log a debug message */
void ppp_info(const char fmt, ...);      / log an informational message */
void ppp_notice(const char fmt, ...);    / log a notice-level message */
void ppp_warn(const char fmt, ...);      / log a warning message */
void ppp_error(const char fmt, ...);     / log an error message */
void ppp_fatal(const char fmt, ...);     / log an error message and die(1) */
#else
#define ppp_dbglog(...)     do {} while(0)  /* log a debug message */
#define ppp_info(...)       do {} while(0)  /* log an informational message */
#define ppp_notice(...)     do {} while(0)  /* log a notice-level message */
#define ppp_warn(...)       do {} while(0)  /* log a warning message */
#define ppp_error(...)      do {} while(0)  /* log an error message */
#define ppp_fatal(...)      do {} while(0)  /* log an error message and die(1) */
#endif
and small sources tuning to suppress warnings about unused variables reduces executable size for more than 5 Kbytes on Cortex-M3 target, saves more than 1 K RAM on lwip main process stack and makes code faster by not executing needless code.

Sergey A. Borshch <dushevny>

 

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Updated the item)
  • -email is unavailable- added by gradator (Updated the item)
  • -email is unavailable- added by dushevny (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-10 goldsimon StatusConfirmed Fixed
        Assigned togradator goldsimon
        Open/ClosedOpen Closed
    2020-01-10 goldsimon Attached File- Added 0001-ppp-don-t-link-debug-functions-if-disabled.patch, #48199
    2018-12-18 gradator Severity3 - Normal 1 - Wish
        StatusNone Confirmed
        Assigned toNone gradator

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code