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

Warnings building with NativeEthernet #34

Open
ktgilliam opened this issue Sep 11, 2023 · 1 comment
Open

Warnings building with NativeEthernet #34

ktgilliam opened this issue Sep 11, 2023 · 1 comment

Comments

@ktgilliam
Copy link

I'm trying to track down several issues that have come up with my code projects, and I'm not sure if this is related but I have noticed now that when I build anything using NativeEthernet.h the compiler generates several warnings. The warnings occur both using PlatformIO IDE and Arduino IDE 2.2.1.

For example, when building the code:

//#include <Arduino.h> //Uncommented when using platformio
#include <NativeEthernet.h>

EthernetServer *tcpServer;
void setup() {
    tcpServer = new EthernetServer(1234);
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

The compiler generates the following warnings:

C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\NativeEthernet\src\NativeEthernetServer.cpp: In member function 'EthernetClient EthernetServer::available()':
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\NativeEthernet\src\NativeEthernetServer.cpp:119:103: warning: enum constant in boolean context [-Wint-in-bool-context]
  119 |                                            if(socket_poll.events_occurred & (FNET_SOCKET_EVENT_OUT || FNET_SOCKET_EVENT_IN)) {
      |                                                                                                       ^~~~~~~~~~~~~~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\service\llmnr\fnet_llmnr.c:60:30: warning: 'fnet_llmnr_ip6_multicast_addr' defined but not used [-Wunused-const-variable=]
   60 | static const fnet_ip6_addr_t fnet_llmnr_ip6_multicast_addr = FNET_IP6_ADDR_INIT(0xFF, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0x00, 0x03);
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:1062:83: warning: argument 2 of type 'unsigned char[36]' with mismatched bound [-Warray-parameter=]
 1062 | MBEDTLSFLASHMEM void ssl_calc_verify_tls( mbedtls_ssl_context *ssl, unsigned char hash[36] )
      |                                                                     ~~~~~~~~~~~~~~^~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:483:73: note: previously declared as 'unsigned char *'
  483 | MBEDTLSFLASHMEM static void ssl_calc_verify_tls( mbedtls_ssl_context *, unsigned char * );
      |                                                                         ^~~~~~~~~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:1090:90: warning: argument 2 of type 'unsigned char[32]' with mismatched bound [-Warray-parameter=]
 1090 | MBEDTLSFLASHMEM void ssl_calc_verify_tls_sha256( mbedtls_ssl_context *ssl, unsigned char hash[32] )
      |                                                                            ~~~~~~~~~~~~~~^~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:490:79: note: previously declared as 'unsigned char *'
  490 | MBEDTLSFLASHMEM static void ssl_calc_verify_tls_sha256( mbedtls_ssl_context *,unsigned char * );
      |                                                                               ^~~~~~~~~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:1111:90: warning: argument 2 of type 'unsigned char[48]' with mismatched bound [-Warray-parameter=]
 1111 | MBEDTLSFLASHMEM void ssl_calc_verify_tls_sha384( mbedtls_ssl_context *ssl, unsigned char hash[48] )
      |                                                                            ~~~~~~~~~~~~~~^~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:496:80: note: previously declared as 'unsigned char *'
  496 | MBEDTLSFLASHMEM static void ssl_calc_verify_tls_sha384( mbedtls_ssl_context *, unsigned char * );
      |                                                                                ^~~~~~~~~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c: In function 'ssl_calc_verify_tls_sha384':
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:1120:5: warning: 'mbedtls_sha512_finish_ret' accessing 64 bytes in a region of size 48 [-Wstringop-overflow=]
 1120 |     mbedtls_sha512_finish_ret( &sha512, hash );
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:1120:5: note: referencing argument 2 of type 'unsigned char *'
In file included from C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\mbedtls/ssl_internal.h:43,
                 from C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:48:
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\mbedtls/sha512.h:128:21: note: in a call to function 'mbedtls_sha512_finish_ret'
  128 | MBEDTLSFLASHMEM int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c: In function 'ssl_calc_finished_tls_sha384':
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:5376:5: warning: 'mbedtls_sha512_finish_ret' accessing 64 bytes in a region of size 48 [-Wstringop-overflow=]
 5376 |     mbedtls_sha512_finish_ret( &sha512, padbuf );
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:5376:5: note: referencing argument 2 of type 'unsigned char *'
In file included from C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\mbedtls/ssl_internal.h:43,
                 from C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\ssl_tls.c:48:
C:\Users\kevin\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\libraries\FNET\src\third_party\mbedtls-2.12.0\src\mbedtls/sha512.h:128:21: note: in a call to function 'mbedtls_sha512_finish_ret'
  128 | MBEDTLSFLASHMEM int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
Memory Usage on Teensy 4.1:
  FLASH: code:214332, data:74204, headers:8416   free for files:7829512
   RAM1: variables:31584, code:75992, padding:22312   free for local variables:394400
   RAM2: variables:12448  free for malloc/new:511840

Is this expected behavior? Like I said, just trying to figure out if it is related to a number of problems that have suddenly come up with my Teensy code projects.

Thanks.

@curtwelch
Copy link

The first error I spotted as well as an obvious sloppy coding error. I too have been looking at errors in my project. Bu in this cast it's harmless because it's only part of debug print that is commented out.

These are the lines in context:

				   if(socket_poll.events_occurred & (FNET_SOCKET_EVENT_OUT || FNET_SOCKET_EVENT_IN)) {

// Serial.println("Socket Event Both");
// break;

It was trying to do an if to check if both the bits were set, but that sure the hell isn't the way to do that. It used logical OR instead of bit-wise OR but even that wouldn't fix it. It should be more like this:

if ((socket_poll.events_occurred & FNET_SOCKET_EVENT_OUT) &&
(socket_poll.events_occurred & FNET_SOCKET_EVENT_IN)) {

But since the only thing that if() did was trigger a pritln() for debugging that is commented out, it has no effect. But leaving broken code in a release that generates warnings sure is sloppy practice.
.

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

No branches or pull requests

2 participants