Boo0ns / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Ethernet interface should use const parameters for pointers to constant data #502

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?

Currently the Ethernet (and subsystems) use parameters like uint8_t *mac, being 
pointers to MAC or IP addresses, as well as data packets.  These parameters do 
not and should not modify these bytes, and this should be explicitly declared 
in the interfaces.

Why?

Otherwise the user is left wondering whether the function might modify the MAC 
or IP address bytes, and whether they are safe to be resized for successive 
calls.

Would this cause any incompatibilities with previous versions?  If so, how can 
these be mitigated?

This should not cause any incompatibilities, but subsystems will need to ensure 
they properly use const pointer parameters or the higher level functions with 
const parameters will not be able to pass their data in.

Attached is a diff affecting Ethernet.{cpp,h} Udp.{cpp,h} socket.{cpp,h} 
w5100.{cpp,h}

Original issue reported on code.google.com by pe...@stairways.com.au on 10 Mar 2011 at 2:23

Attachments:

GoogleCodeExporter commented 9 years ago
Sounds good, although we're probably making other changes to the interface that 
will replace the char pointers with an IPAddress class: 
https://github.com/arduino/Arduino/pull/20

Original comment by dmel...@gmail.com on 10 Mar 2011 at 4:03

GoogleCodeExporter commented 9 years ago
Here is a new patch for the IPAddress version

Original comment by pe...@stairways.com.au on 29 Mar 2011 at 1:03

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 24 Aug 2011 at 6:51

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 16 Dec 2011 at 10:08