buglwIP - A Lightweight TCP/IP stack - Bugs: bug #58650, Cast increases required alignment...

 
 

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

bug #58650: Cast increases required alignment warning in debug output

Submitter:  Ashley Duncan <ashesman>
Submitted:  Wed 24 Jun 2020 05:12:42 AM UTC
   
 
Category:  DNS Severity:  3 - Normal
Item Group:  Compiler Warning Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  2.1.1

Wed 15 Sep 2021 06:07:28 AM UTC, comment #3: 

Not really required, but I've cherry-picked it anyway.

Simon Goldschmidt <goldsimon>
Group administrator
Wed 15 Sep 2021 04:26:29 AM UTC, comment #2: 

This issue was reported on v2.1.2.
Is it required to have this fix for v2.1.3?

Axel Lin <axellin>
Group Member
Fri 05 Mar 2021 12:22:31 PM UTC, comment #1: 

Fixed, thanks for reporting.

Simon Goldschmidt <goldsimon>
Group administrator
Wed 24 Jun 2020 05:12:42 AM UTC, original submission:  

On version 2.1.2

A very trivial thing but when enabling DNS_DEBUG, line 132 of netdb.c causes a cast increases required alignment warning (or error in my case) due to the cast of a char to a ip_addr_t .  Here is a proposed (but untested) fix, it is not the most efficient, but it is only debug output display.

In this case it can be guaranteed that there is not an alignment issue, so the cast cannot cause a runtime error.

An alternate may be to cast through a uintptr_t.

Original:

 LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n", idx, ipaddr_ntoa((ip_addr_t *)s_hostent.h_addr_list[idx])));

Proposed Fix:

      /* memcpy prevents cast increases required alignment warning */
      memcpy(&addr, s_hostent.h_addr_list[idx], sizeof(addr));
      LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n", idx, ipaddr_ntoa(&addr)));

Ashley Duncan <ashesman>

 

(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 axellin (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by ashesman (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-03-05 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code