Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct compilation of arch/sim/src/sim/up_wpcap.c #1903

Merged
merged 1 commit into from
Sep 28, 2020

Conversation

patacongo
Copy link
Contributor

@patacongo patacongo commented Sep 27, 2020

Summary

This PR corrects this build error:

/usr/include/cygwin/socket.h:27:8: error: redefinition of 'struct sockaddr'
   27 | struct sockaddr {
      |        ^~~~~~~~
In file included from /usr/include/w32api/winsock2.h:57,
                 from sim/up_wpcap.c:48:
/usr/include/w32api/psdk_inc/_ip_types.h:70:8: note: originally defined here
   70 | struct sockaddr {
      |        ^~~~~~~~
In file included from /usr/include/sys/socket.h:13,
                 from /usr/include/cygwin/in.h:21,
                 from /usr/include/netinet/in.h:12,
                 from sim/up_wpcap.c:57:
/usr/include/cygwin/socket.h:39:8: error: redefinition of 'struct sockaddr_storage'
   39 | struct sockaddr_storage {
      |        ^~~~~~~~~~~~~~~~
In file included from sim/up_wpcap.c:48:
/usr/include/w32api/winsock2.h:269:10: note: originally defined here
  269 |   struct sockaddr_storage {
      |          ^~~~~~~~~~~~~

The compilation was broken by a couple of recent blind, unverified changes to up_wpcap.c. Most were introduced with commit: 8ce0ff5 with this change:

diff --git a/arch/sim/src/sim/up_wpcap.c b/arch/sim/src/sim/up_wpcap.c
index ef7b4b3a0c..a15421e80c 100644
--- a/arch/sim/src/sim/up_wpcap.c
+++ b/arch/sim/src/sim/up_wpcap.c
@@ -55,6 +55,8 @@

 #include <netinet/in.h>

+#include "up_internal.h"
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/

up_internal.h includes:

 47 #  include <sys/types.h>
 48 #  include <stdbool.h>
 49 #  include <netinet/in.h>

And netinet/in.h includes:

 46 #include <sys/types.h>
 47 #include <sys/socket.h>
 48 #include <stdint.h>

Which is where the collision error is introduced since up_wpcap.c includes winsock2.h already. There were additional problems introduced to the file by other changes:

  • A malformed syslog() call was added
  • Some issues with netdriver_setmacaddr()

Impact

This corrects the compilation of up_wpcap.c. It should affect only simulator builds for simulator

Testing

I verified only that the sim:nettest configuration still builds. The WPCAP configuration has not been verified in many years. It would not surprise if there are not additional issues.

This commit corrects the following compilation error:

    /usr/include/cygwin/socket.h:27:8: error: redefinition of 'struct sockaddr'
       27 | struct sockaddr {
          |        ^~~~~~~~
    In file included from /usr/include/w32api/winsock2.h:57,
                     from sim/up_wpcap.c:48:
    /usr/include/w32api/psdk_inc/_ip_types.h:70:8: note: originally defined here
       70 | struct sockaddr {
          |        ^~~~~~~~
    In file included from /usr/include/sys/socket.h:13,
                     from /usr/include/cygwin/in.h:21,
                     from /usr/include/netinet/in.h:12,
                     from sim/up_wpcap.c:57:
    /usr/include/cygwin/socket.h:39:8: error: redefinition of 'struct sockaddr_storage'
       39 | struct sockaddr_storage {
          |        ^~~~~~~~~~~~~~~~
    In file included from sim/up_wpcap.c:48:
    /usr/include/w32api/winsock2.h:269:10: note: originally defined here
      269 |   struct sockaddr_storage {
          |          ^~~~~~~~~~~~~

The compilation was broken by a couple of recent blind, unverified changes to up_wpcap.c.  Most were introduced with commit: 8ce0ff5 with this change:

    diff --git a/arch/sim/src/sim/up_wpcap.c b/arch/sim/src/sim/up_wpcap.c
    index ef7b4b3a0c..a15421e80c 100644
    --- a/arch/sim/src/sim/up_wpcap.c
    +++ b/arch/sim/src/sim/up_wpcap.c
    @@ -55,6 +55,8 @@

     #include <netinet/in.h>

    +#include "up_internal.h"
    +
     /****************************************************************************
      * Pre-processor Definitions
      ****************************************************************************/

up_internal.h includes:

     47 #  include <sys/types.h>
     48 #  include <stdbool.h>
     49 #  include <netinet/in.h>

And netinet/in.h includes:

     46 #include <sys/types.h>
     47 #include <sys/socket.h>
     48 #include <stdint.h>

Which is where the collision error is introduced since up_wpcap.c includes winsock2.h already.  There were additional problems introduced to the file by other changes:

- A malformed syslog() call was added
- Some issues with netdriver_setmacaddr()
@patacongo
Copy link
Contributor Author

Please ignore all of the Mixed Case identifier problems that cause the check to fail. These are due to calls directly into the Windows networking logic which follow standard Windows CamelCase naming conventions. There is no way around that.

@btashton
Copy link
Contributor

I still have some issues running the all the binaries generated from sim builds in Cygwin, but this does resolve the build issue.

@btashton btashton merged commit fe0a88c into apache:master Sep 28, 2020
@patacongo patacongo deleted the wpcap branch September 30, 2020 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants