buglwIP - A Lightweight TCP/IP stack - Bugs: bug #51463, posix/errno.h incompatible with...

 
 

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

bug #51463: posix/errno.h incompatible with LWIP_ERRNO_STDINCLUDE

Submitted by:  Joel Cunningham <jcunningham>
Submitted on:  Fri 14 Jul 2017 12:17:03 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Change RequestStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: git head

(Jump to the original submission Jump to the original submission)

Thu 20 Jul 2017 08:23:55 PM UTC, comment #10:

Great! Thanks for quick turn-around :)

Joel Cunningham <jcunningham>
Project Member
Thu 20 Jul 2017 08:12:41 PM UTC, comment #9:

Yes. I've just pushed it :-)

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Mon 17 Jul 2017 07:34:31 PM UTC, comment #8:

compat folder sounds like a good idea to me:

So you're thinking:

lwip/src/include/compat/posix/...
lwip/src/include/compat/stdc/errno.h?

Joel Cunningham <jcunningham>
Project Member
Mon 17 Jul 2017 07:01:38 PM UTC, comment #7:

OK, all the other files seem net-related.

Is it worth moving the existing files for clarity and to prevent having even more directories under "src/include"? In that case, I'd rather create a folder "compat" to clearly mark the beginning of compatibility-only header files and from there branch to subfolders...

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Mon 17 Jul 2017 03:57:31 PM UTC, comment #6:

> Seems like errno.h would need a different directory then?


That's what I was thinking too. What about the following organization:

lwip/src/include/posix/... (contains the POSIX networking headers)
lwip/src/include/stdc/errno.h (contains ISO standard C headers)

Or we could introduce a 'clib' folder for c library headers, under which you'd have both a posix and stdc:

lwip/src/include/clib/posix/...
lwip/src/include/clib/stdc/errno.h

This link (https://en.wikipedia.org/wiki/C_POSIX_library) was helpful in understanding the relationship of the POSIX C library to ISO standard C (POSIX is a superset).

Joel Cunningham <jcunningham>
Project Member
Sun 16 Jul 2017 06:09:31 PM UTC, comment #5:

No, I guess not. Seems like errno.h would need a different directory then?

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Fri 14 Jul 2017 06:29:21 PM UTC, comment #4:

> In other words, having both LWIP_ERRNO_STDINCLUDE==1 and the "include/posix" in your include paths is not meant to work (yet?) ;-)


Thinking about this more, the posix/errno.h with LWIP_PROVIDE_ERRNO == 1 is only safe if the C library doesn't also provide errno.h because other source files in the project may be compiled against the standard C library version (depending on include paths during compilation) and you'll end up with a binary incompatibility between object files if underlying values don't match.

Have you worked with embedded toolchains where errno.h is not provided by the standard C library? I typically use the ARM C Compiler and GCC ARM Embedded, both provide errno.h, but none of the BSD socket (later standardized to POSIX) headers.

Joel Cunningham <jcunningham>
Project Member
Fri 14 Jul 2017 05:48:53 PM UTC, comment #3:

In other words, having both LWIP_ERRNO_STDINCLUDE==1 and the "include/posix" in your include paths is not meant to work (yet?) ;-)

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Fri 14 Jul 2017 05:47:56 PM UTC, comment #2:

Well, the whole purpose of the 'posix' subtree is to provide standard definitions for those header files if wanted (i.e. if they don't exist otherwise).

Now you seem to want other standard files but not errno.h. That might be a valid thing to do, but I don't see how we could achieve that other than creating a separate include directory for all of those files?

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Fri 14 Jul 2017 02:35:09 PM UTC, comment #1:

I enabled some include tree debugging and found another broken case:

application code (#include "lwip/socket.h") -> lwip/errno.h -> posix/errno.h -> lwip/errno.h -> nop

Since I'm using LWIP_ERRNO_STDINCLUDE, lwip/errno.h should be picking up stdclib errno.h. See attachment for full include tree

In comment #1, I had described the following case:

application code (include <errno.h>) -> posix/errno.h -> lwip/errno.h -> posix/errno.h -> lwip/errno.h -> nop

(file #41204)

Joel Cunningham <jcunningham>
Project Member
Fri 14 Jul 2017 12:17:03 AM UTC, original submission:

In my port, I'm trying to make use of the posix compatibility headers and have LWIP_ERRNO_STDINCLUDE set to 1. In my project, the standard C library errno.h is the canonical one.

posix/errno.h is creating a problem because once in the build system, files are picking it up and then it includes lwip/errno.h, which is empty because LWIP_ERRNO_STDINCLUDE is trying to include the standard C library errno.h, but gets posix/errno.h (lwip/errno.h does not get included again due to #ifndef LWIP_HDR_ERRNO_H).

I've confirmed this by deleting posix/errno.h and things work as expected, with the standard C library errno.h now satisfying the dependency

Was the motivation behind the posix/errno.h addition to allow LwIP to provide a canonical errno.h for the entire project (LwIP sources + other files)? I like this idea, but would prefer it be separate from the posix headers (my build system can't blacklist a single header). Also, errno.h is part of the standard C library, would it make more sense as include/stdclib/errno.h?

Thanks

Joel Cunningham <jcunningham>
Project Member

 

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

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

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 20 Jul 2017 08:12:41 PM UTCgoldsimonStatusNone=>Fixed
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed
    Fri 14 Jul 2017 02:35:09 PM UTCjcunninghamAttached File-=>Added socket-h-posix-errno-tree.txt, #41204

    Back to the top


    Powered by Savane 3.1-cleanup1