Commit Graph

439 Commits

Author SHA1 Message Date
Matthijs Kooijman 33df998351 Fix bounds check in String::remove()
Previously, if you passed in a very big index and/or count, the
`index + count` could overflow, making the count be used as-is instead
of being truncated (causing the string to be updated wrongly and
potentially writing to arbitrary memory locations).

We can rewrite the comparison to use `len - index` instead. Since we
know that index < len, we are sure this subtraction does not overflow,
regardless of what values of index and count we pass in.

As an added bonus, the `len - index` value already needed be calculated
inside the if, so this saves a few instructions in the generated code.

To illustrate this problem, consider this code:

String foo = "foo";
Serial.println(foo.length()); // Prints 3
foo.remove(1, 65535); // Should remove all but first character
Serial.println(foo.length()); // Prints 4 without this patch

Not shown in this is example is that some arbitrary memory is written
as well.
2014-09-10 12:33:25 +02:00
Matthijs Kooijman 57b3cf3203 Remove unneeded check in String::remove(unsigned int)
This check already happens in the remove(unsigned int, unsigned int)
method that is caled, so there is no need to also check this here.
2014-09-10 12:33:24 +02:00
Cristian Maglie 10d20cc11a Fixed license for new.cpp and small cosmetic changes 2014-09-06 12:44:53 +02:00
Cristian Maglie 878c05a4e2 Correct implementation of gcc specific internal functions
The following empty stubs has been replaced by the gcc
flag -fno-threadsafe-static:

  int __cxa_guard_acquire(__guard *);
  void __cxa_guard_release (__guard *);
  void __cxa_guard_abort (__guard *);

The following empty stubs has been moved into their specific
module abi.cpp:

  void __cxa_pure_virtual(void) __attribute ((noreturn));
  void __cxa_deleted_virtual(void) __attribute ((noreturn));

Fix #107
2014-09-06 12:42:25 +02:00
Cristian Maglie 2d92a94dff Printable.h doesn't need new.h but only stdlib.h for size_t.
Probalby new.h may be removed completely.
2014-09-06 12:37:57 +02:00
Cristian Maglie 50c1c5852a Updated version to 1.5.8 2014-09-05 10:11:47 +02:00
Cristian Maglie 5adeef3b5e Fix for upload problems on Arduino Leonardo (and derivatives) with OSX 10.9.4 2014-09-01 12:16:41 +02:00
Cristian Maglie 13945aee9f Merge branch 'master' into ide-1.5.x 2014-08-08 15:44:41 +02:00
PaulStoffregen 3791e4f260 SPI Transactions for AVR 2014-08-01 05:38:27 -07:00
Cristian Maglie 7a299b790a Merge remote-tracking branch 'arduino/master' into ide-1.5.x 2014-07-24 14:46:05 +02:00
Cristian Maglie 3b711a1e3b Merge pull request #2194 from Fede85/ide-1.5.x_lib-description
Ide 1.5.x lib description
2014-07-21 12:16:20 +02:00
Cristian Maglie 6a4c3791ce Merge pull request #2190 from ribbons/compiler-warnings
Fix two compiler warnings generated by updated toolchain
2014-07-19 09:35:58 +02:00
Fede85 518c5a0fad missing paragraph field in library.properties 2014-07-18 20:08:01 +02:00
Fede85 4fa3f300b7 modified sentences in library.properties files 2014-07-18 19:41:34 +02:00
PaulStoffregen 811d053d65 Add availableForWrite() to HardwareSerial 2014-07-18 07:01:26 -07:00
Matt Robinson e9d8646952 Cast empty string to char* to fix compiler warning
Stream::find(char *target) passes an empty terminator string to
Stream::findUntil(char *target, char *terminator) which caused a compiler
warning with the updated toolchain, so cast it to a char*.
2014-07-17 16:51:35 +01:00
Cristian Maglie d767faae30 Merge pull request #1912 from Lauszus/issues440
Enable user to change the I2C clock frequency by calling setClock in the Wire library
2014-07-02 15:37:30 +02:00
Cristian Maglie 2b706ab591 Merge pull request #2148 from Lauszus/promini
Arduino Pro and Pro Mini should use eightanaloginputs variant
2014-07-02 15:29:31 +02:00
Fede85 4bde528f5e added support for the ArduinoISP 2014-07-02 15:03:12 +02:00
Cristian Maglie f6dfdf5804 Update ArduinoWifiShield_upgrade_mac.sh 2014-07-01 19:11:19 +02:00
Ankit Daftery 95a53045b4 Update ArduinoWifiShield_upgrade.sh
File path should be updated, is wrong currently, will throw an error saying files missing.
2014-07-01 19:09:49 +02:00
Cristian Maglie 55c0101ab9 Merge branch 'master' into ide-1.5.x 2014-07-01 19:07:55 +02:00
Cristian Maglie 3804340f88 Merge branch 'ide-1.5.x-timer-variant' of github.com:matthijskooijman/Arduino into matthijskooijman-ide-1.5.x-timer-variant 2014-07-01 18:29:07 +02:00
Cristian Maglie 0fea0204bd Reverting -flto flag from AVR core until all compatibility problems are worked out.
For more info:
https://groups.google.com/a/arduino.cc/d/msg/developers/21G5w2HbUOg/NRMW6c9OIFUJ
2014-07-01 17:18:04 +02:00
Kristian Lauszus 0032851a32 Arduino Pro and Pro Mini should use eightanaloginputs variant, so all 8 analog pins can be used 2014-06-28 22:37:26 +02:00
Cristian Maglie 3cdb1c7a57 Merge branch 'ide-1.5.7' into ide-1.5.x 2014-06-27 13:44:18 +02:00
Matthijs Kooijman 3745139b67 Support Atmega8 (and similar that define PE instead of UPE) again
These chips were previously supported, but since parity error checking
was added, this support has broken. Most chips define UPE0 (etc.) for
the parity error bit. Some chips don't have numbered UARTS so only
define UPE and even fewer define PE instead of UPE. This adds support
for those chips again.

Closes: #2137
2014-06-25 17:20:07 +02:00
Matthijs Kooijman c5bdb51ba6 Allow variants to define an initVariant() function that is called at startup.
See #2080 and #2139.
2014-06-25 16:56:19 +02:00
Cristian Maglie a8632e7b1f Removed patch for old malloc bug (no more useful with updated toolchain) 2014-06-25 10:14:35 +02:00
Federico Fissore 06b9d6f45c Fixed compilation error when targetting Mega. Error is caused by #2039 and this fix is just a workaround 2014-06-25 10:14:35 +02:00
Federico Fissore 3094d75b5a gcc: Adding -w flag to compiler.c.elf.flags in order to avoid printing ISR warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396 2014-06-25 10:14:35 +02:00
Federico Fissore 8090a955c1 Enabling link-time optimization. See #660 2014-06-25 10:14:34 +02:00
Federico Fissore 58822f062e New common AVR toolchain 2014-06-25 10:12:39 +02:00
Cristian Maglie 2632f64a75 Merge branch 'master' into ide-1.5.x 2014-06-19 17:01:53 +02:00
Cristian Maglie 887a6faa7c Merge branch 'master' into HEAD 2014-06-13 10:29:12 +02:00
Cristian Maglie fe3196f9b6 Merge branch 'master' into HEAD 2014-05-30 10:54:14 +02:00
Cristian Maglie 8ffc54f4ca Merge branch 'usbcdc-improved' into ide-1.5.x 2014-05-26 13:38:07 +02:00
Cristian Maglie e1aff134d0 Merge branch 'ide-1.5.x-hwserial-cleanup' of github.com:matthijskooijman/Arduino into matthijskooijman-ide-1.5.x-hwserial-cleanup 2014-05-23 21:16:42 +02:00
Cristian Maglie 41975bf4f9 Merge remote-tracking branch 'arduino/master' into ide-1.5.x
Conflicts:
	build/shared/examples/01.Basics/Blink/Blink.ino
	build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino
	build/shared/examples/10.StarterKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino
	hardware/arduino/cores/arduino/HardwareSerial.cpp
2014-05-23 21:04:47 +02:00
Matthijs Kooijman 3be0f630ba Support TIMER1C
Some devices, such as the atmega2560 or the atmega256rfr2 have a timer1c
output. It seems this output is not connected to anything on the Arduino
Mega, but this allows using it on third party hardware nonetheless.
2014-05-16 18:57:04 +02:00
Matthijs Kooijman 462e5137cf Remove unneeded register and ISR names in HardwareSerialx.cpp
Before, HardwareSerial1+.cpp were a copy of HardwareSerial1.cpp with all
0's replaced by the corresponding number. This would mean that e.g.
the Serial1 object would use the UBRRL register instead of UBRR1L when
it was defined, or the USART_RX_vect instead of USART1_RX_vect.

In practice, this would neve actually cause problems, since:
 - No avr chip currently has both the non-numbered registers as well as
   numbered registers.
 - HardwareSerial.h would only define HAVE_HWSERIALx when the
   corresponding numbered register is defined (except for
   HAVE_HWSERIAL0, which is also defined when the unnumbered registers
   are present).

Furthermore, before both the UARTx_xx_vect and USART_x_xx_vect was used.
Looking at the include files, only UART1_xx_vect is actually used (by
iom161.h), the others use USARTx_xx_vect. For this reason,
HardwareSerial1.cpp keeps the preprocessor conditional to select either
UART or USART and the other files use USART unconditionally.

While we're here, also fix the compiler error message when no valid ISR
name was found (it previously said "for the first UART" in all cases).
2014-05-06 10:26:46 +02:00
Matthijs Kooijman 8ff4b9acae Fix comment typo 2014-05-06 10:19:08 +02:00
Matthijs Kooijman 5fe959e8c7 Fix EXTERNAL_NUM_INTERRUPTS for atmega128rfa1 and atmega256rfr2 2014-05-02 12:50:07 +02:00
Cristian Maglie 94d9a9d1f8 Fixed other trivial warnings in AVR USB core.
See #1877
2014-04-20 23:08:55 +02:00
Cristian Maglie a1064ac20b Removed other unused variables in CDC.cpp and HID.cpp
See #1877
2014-04-20 20:56:51 +02:00
Cristian Maglie 5c8bb5aa71 Removed 'USB_MANUFACTURER' constant redefinition for known VIDs.
See #1877
2014-04-20 20:49:04 +02:00
Cristian Maglie 2d606a402d Merge branch 'ide-1.5.x-warnings' of github.com:matthijskooijman/Arduino into ide-1.5.x 2014-04-20 19:36:29 +02:00
Matthijs Kooijman b3779a9cae Explicitly define compiler.path in avr/platform.txt
Previously, this relied on an (ugly, avr-specific) magic default for the
compiler.path variable, set by the IDE. This allowed the IDE to fall
back to a system-wide toolchain when no bundled toolchain was found (by
making compiler.path empty).

However,
 - this only worked for avr, not sam,
 - this worked only for gcc, a system-wide avrdude would break on the
   avrdude.conf path in platform.txt, and

This would mean that automatic system-wide fallback didn't work in all
situations, so you'd still have to modify platform.txt (or create
platform.local.txt). Since doing that explictly is the most reliable
way, this commit removes the partial-working ability to do this
automatically.

Note that the code to automatically set compiler.path is still kept
around, in case third-party hardware still relies on this. At some
point, this code should be removed, but for now it just shows a warning
message.
2014-04-10 12:19:43 +02:00
Matthijs Kooijman 91150b60a5 Add (empty) compiler.*.extra_flags variables in platform.txt
These make it easier for a user to add extra compiler flags in a
platform.local.txt file.
2014-04-04 11:31:50 +02:00
Cristian Maglie 64a0cc11ce Merge commit '1ad74' into ide-1.5.x 2014-04-01 17:19:54 +02:00