arduino-libraries / Servo

Servo Library for Arduino
http://arduino.cc/
GNU Lesser General Public License v2.1
257 stars 263 forks source link

Fix min/max private variables overflow #101

Open bleubidon opened 2 years ago

bleubidon commented 2 years ago

Using an int8_t for min and max causes the computation of this->min and this->max in Servo::attach(int pin, int min, int max) to overflow (for instance when calling my_servo.attach(my_pin, 544, 1100), following https://www.arduino.cc/reference/en/libraries/servo/attach/).

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

github-actions[bot] commented 2 years ago

Memory usage change @ 7b4f26462c5053ac967b237c602000ad9ba54200

Board flash % RAM for global variables %
arduino:avr:leonardo :small_red_triangle: +8 - +8 +0.03 - +0.03 :small_red_triangle: +2 - +2 +0.08 - +0.08
arduino:avr:mega :small_red_triangle: +8 - +8 0.0 - 0.0 :small_red_triangle: +2 - +2 +0.02 - +0.02
arduino:avr:nano :small_red_triangle: +8 - +8 +0.03 - +0.03 :small_red_triangle: +2 - +2 +0.1 - +0.1
arduino:mbed_nano:nano33ble :green_heart: -64 - 0 -0.01 - 0.0 :small_red_triangle: +8 - +8 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect :green_heart: -4 - -4 -0.0 - -0.0 :small_red_triangle: +8 - +8 0.0 - 0.0
arduino:mbed_portenta:envie_m4 0 - 0 0.0 - 0.0 :small_red_triangle: +8 - +8 0.0 - 0.0
arduino:mbed_portenta:envie_m7 0 - 0 0.0 - 0.0 :small_red_triangle: +8 - +8 0.0 - 0.0
arduino:megaavr:nona4809 :small_red_triangle: +8 - +8 +0.02 - +0.02 :small_red_triangle: +2 - +2 +0.03 - +0.03
arduino:sam:arduino_due_x_dbg :green_heart: -16 - -8 -0.0 - -0.0 N/A N/A
arduino:samd:mkrzero :green_heart: -8 - -8 -0.0 - -0.0 :small_red_triangle: +8 - +8 +0.02 - +0.02
Click for full report table Board|examples/Knob
flash|%|examples/Knob
RAM for global variables|%|examples/Sweep
flash|%|examples/Sweep
RAM for global variables|% -|-|-|-|-|-|-|-|- arduino:avr:leonardo|8|0.03|2|0.08|8|0.03|2|0.08 arduino:avr:mega|8|0.0|2|0.02|8|0.0|2|0.02 arduino:avr:nano|8|0.03|2|0.1|8|0.03|2|0.1 arduino:mbed_nano:nano33ble|0|0.0|8|0.0|-64|-0.01|8|0.0 arduino:mbed_nano:nanorp2040connect|-4|-0.0|8|0.0|-4|-0.0|8|0.0 arduino:mbed_portenta:envie_m4|0|0.0|8|0.0|0|0.0|8|0.0 arduino:mbed_portenta:envie_m7|0|0.0|8|0.0|0|0.0|8|0.0 arduino:megaavr:nona4809|8|0.02|2|0.03|8|0.02|2|0.03 arduino:sam:arduino_due_x_dbg|-16|-0.0|N/A|N/A|-8|-0.0|N/A|N/A arduino:samd:mkrzero|-8|-0.0|8|0.02|-8|-0.0|8|0.02
Click for full report CSV ``` Board,examples/Knob
flash,%,examples/Knob
RAM for global variables,%,examples/Sweep
flash,%,examples/Sweep
RAM for global variables,% arduino:avr:leonardo,8,0.03,2,0.08,8,0.03,2,0.08 arduino:avr:mega,8,0.0,2,0.02,8,0.0,2,0.02 arduino:avr:nano,8,0.03,2,0.1,8,0.03,2,0.1 arduino:mbed_nano:nano33ble,0,0.0,8,0.0,-64,-0.01,8,0.0 arduino:mbed_nano:nanorp2040connect,-4,-0.0,8,0.0,-4,-0.0,8,0.0 arduino:mbed_portenta:envie_m4,0,0.0,8,0.0,0,0.0,8,0.0 arduino:mbed_portenta:envie_m7,0,0.0,8,0.0,0,0.0,8,0.0 arduino:megaavr:nona4809,8,0.02,2,0.03,8,0.02,2,0.03 arduino:sam:arduino_due_x_dbg,-16,-0.0,N/A,N/A,-8,-0.0,N/A,N/A arduino:samd:mkrzero,-8,-0.0,8,0.02,-8,-0.0,8,0.02 ```