lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #58650] Cast increases required alignment warning in d


From: Ashley Duncan
Subject: [lwip-devel] [bug #58650] Cast increases required alignment warning in debug output
Date: Wed, 24 Jun 2020 01:12:44 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36

URL:
  <https://savannah.nongnu.org/bugs/?58650>

                 Summary: Cast increases required alignment warning in debug
output
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: ashesman
            Submitted on: Wed 24 Jun 2020 05:12:42 AM UTC
                Category: DNS
                Severity: 3 - Normal
              Item Group: Compiler Warning
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: 2.1.1

    _______________________________________________________

Details:

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




    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?58650>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]